
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
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.
- Related Articles
- What is the type of string literals in C/ C++?
- Type difference of character literals in C and C++
- What are string literals in C#?
- What are string literals in C language?
- Type difference of character literals in C vs C++
- Formatted string literals in C#
- What is the difference between character literals and string literals in Java?
- What does the @ prefix do on string literals in C#?
- What happen if we concatenate two string literals in C++?
- Character constants vs String literals in C#
- What are literals in C++?
- What are Boolean Literals in C++?
- What are Character Literals in C++?
- What are integer literals in C#?
- Literals in C#

Advertisements