This is why you can use sizeof( “Hello”)-1 to get the number of characters in the string (including any embedded NUL); if it is a pointer, it will not work because it is always the size of the pointer on your system (minus one). < /p>
I am confused about the data type of string literals. Is it a const char * or a const char?
It is a const char [N] (same as char const [N]), where N is the length of the string plus a terminating NUL (or just the length of the string, if you define “length as a string” NUL is already included”.
This is why you can use sizeof(“hello”) – 1 to get the number of characters in the string (including any embedded NUL); if it is a Pointer, it will not work because it is always the size of the pointer on your system (minus one).