What is the type of string literals in C and C++?

In C the type of a string literal is a char[]. In C++, an ordinary string literal has type 'array of n const char'. For example, The type of the string literal "Hello" is "array of 6 const char". It can, however, be converted to a const char* by array-to-pointer conversion.

Note that Array-to-pointer conversion results in a pointer to the first element of the array.

Lakshmi Srinivas
Lakshmi Srinivas

Programmer / Analyst / Technician