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.

Updated on: 2019-07-30T22:30:21+05:30

778 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements