C++ Programming Code Examples C++ > Strings Code Examples Character and string literals Character and string literals There also exist non-numerical constants, like: 'r' 'p' "Happy Codings - C++ Programming Language Code Examples" "C++ Programming Language | Happy Codings :)" The first two expressions represent single character constants, and the following two represent string literals composed of several characters. Notice that to represent a single character we enclose it in single quotes (') and to express a string (which generally consists of more than one character) we enclose it in double quotes ("). When writing both single character and string literals, it is necessary to put the quotation marks surrounding them to distinguish them from possible variable identifiers or reserved keywords. Notice the difference between these two expressions: x 'x' x alone would refer to a variable whose identifier is x, whereas 'x' (enclosed within single quotation marks) would refer to the character constant 'x'. Character and string literals have certain peculiarities, like the escape codes. These are special characters that are difficult or impossible to express otherwise in the source code of a program, like a newline (\n) or tab (\t). All of them are preceded by a backslash (\). Here you have a list of some of such escape codes: \n newline \r Carriage return \t tab \v vertical tab \b backspace \f form feed (page feed) \a alert (beep) \' single quote (') \" double quote (") \? a question mark (?) \\ backslash (\)