Originally Posted by
brewbuck
To elaborate on this, declaring it as a "char *" causes string to be a pointer to a string literal. Taking sizeof will give the size of that pointer (some small value), not the length of the string. Declaring it as "char []" causes it to be an array of chars. Taking sizeof() of an array always gives the size of the array. Since sizeof(char) is equal to 1, this is the same as taking the length of the string. Beware the null terminator; it is included in this count, unlike the return value of strlen().