String constants given in compiling system memory location can be assigned to the character pointer; at this time can be accessed by index, but can not modify the value of the string by the subscript.
Can modify the value of the string when the character pointer to an array of characters.
#include <stdio.h> #include < String .h> int main () { char A [ 26 is ]; char * B = " ABC " ; // defining initialized B = " 123 " ; // can be reassigned // B [. 1] = 'V'; // can not be modified A [ . 1 ] = B [ . 1 ]; // read by the subscript strcpy (A, " catdog " ); strcat (A, " ! "); B = A; // points to a character array b [ 0 ] = ' X ' ; // may be modified b [ . 1 ] = " X " ; // actually address character constant "x" paid to b [ 1], a string distortion appears the printf ( " % S \ n- " , A); System ( " PAUSE " ); return 0 ; }