Final answer:
Option 3, 'string1[0] = 'C';', is not legal because string1 points to a constant character sequence, which cannot be modified.
Step-by-step explanation:
The student has asked which of the following pieces of code is not legal when considering the declaration char const *string1 = "Go Bucks!";
- printf("%s",string1);
- string1 = "Go!..............................";
- string1[0] = 'C';
- string1 = "Go!";
The correct answer is 3. string1[0] = 'C';. This is because string1 is a pointer to a constant character sequence. You can change where the pointer string1 points to, as demonstrated in cases 2 and 4, but you cannot change the contents of the string itself, as you would attempt to do in case 3. Attempting to modify a constant character sequence (string literal) is illegal in C and will result in a compile-time error.