Pointer to char and Array of char
char *s = "My Brother";
Declares a pointer s to char, initializes it to the starting address of a string.
char c[]= "My Car";
Declares an array c of size 7, with c[0]='M', c[1]='y', …, c[5]='r', c[6] ='\0'.
Then we can say
s = c; Or equivalently s = &c[0];
But NOT
c = "My hand"; or c = s;
Previous slide
Next slide
Back to first slide
View graphic version