We said we could not assign or change the value of the pointer cell corresponding to the name of a string variable, but we can declare another
character pointer, assign it a value (or pass its value in a function), and use it as a string:
char str[81] = "This is a string";
char *s;
This declares a string, str, and an unitiialized character pointer, s.
We can initialize it:
s = str;
Now, s refers to the same string as str.
We can also modify the value of s:
s = str + 2;
W
hat is the value of S?
Now, s refers to a substring of str; namely "is is a string".
That is what we would get if we
printf("%s\n",s);
We can also
s++;
Now, s refers to a different substring of str; namely "s is a string".
That is what we would get if we
printf("%s\n",s);