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

C++ProgrammingObject Oriented Programming

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.

raja
Published on 16-Feb-2018 14:36:26
Advertisements