char namea[] = "earth";
char *pname = "earth";
One is an array (the name namea
refers to a block of characters).
The other is a pointer to a single character (the name pname
refers to a pointer, which just happens to point to the first character of a block of characters).
Although the former will often decay into the latter, that's not always the case. Try doing a sizeof
on them both to see what I mean.
The size of the array is, well, the size of the array (six characters, including the terminal null).
The size of the pointer is dependent on your pointer width (4 or 8, or whatever). The size of what pname
points to is not the array, but the first character. It will therefore be 1.
You can also move pointers with things like pname++
(unless they're declared constant, with something like char *const pname = ...;
of course). You can't move an array name to point to it's second character (namea++;
).