Literals


Syntax

literal:
       character_constant
       integer_constant
       numeric_constant
       string_literal

String literals

A string literal is a sequence of characters enclosed within double quotes. The type of a string literal is an array of char. The storage class of a string literal is static. A compiler initializes the memory occupied by a string literal with the specified character sequence. A null terminator (which denotes the end of the string) is also included. The size a string literal is the number of characters enclosed within the double quotes plus one for the null terminator. The escape characters described in the section on the character data type are also available for the specification of string literals.

The compiler concatenates adjacent string literals. For example, the adjacent string literals:

"Hello" " world"

are concatenated to form the string:

"Hello world".

A string literal prefixed by the letter 'L' is treated as a string of wide characters.

Examples

int i = sizeof("i++");  // i == 4
char logo[] = "i++";    // logo is a character array of size 4