Yes, and your point is?
Whether it's a linked list, and array, a hash-table or some other construction, if you are storing a string as a char *, each value of char * needs to point to a specific place which contains the string you refer to.
To make a simple example (try this on your system)
Code:
char *arr[3];
int main()
{
char str[10] = "Hello";
for(i = 0; i < 3; i++)
arr[i] = str;
strcpy(arr[2], "World");
for(i = 0; i < 3; i++)
printf("arr[%d]=%s\n", i, arr[i]);
return 0;
}
Now do this (changes in red):
Code:
char *arr[3];
char *copystr(char *s)
{
char *p = malloc(strlen(s)+1);
strcpy(p, s);
return p;
}
int main()
{
char str[10] = "Hello";
for(i = 0; i < 3; i++)
arr[i] = copystr(str);
strcpy(arr[2], "World");
for(i = 0; i < 3; i++)
printf("arr[%d]=%s\n", i, arr[i]);
return 0;
}
The same would happen if "str" was inserted into a linked list. I choose an array to make it simple to understand.
--
Mats