What is a string literal in C++?

C++ProgrammingObject Oriented Programming

A string literal or anonymous string is a type of literal in programming for the representation of a string value within the source code. More simply put, a string literal is a bit of text between double quotes. For example,

const char* var = "Hello";

In this definition of var, "Hello" is a string literal. Using const in this way means you can use var to access the string but not to change it. A C++ compiler handles it in the same way as it would handle a character array.

raja
Published on 16-Feb-2018 09:39:10
Advertisements