Loading, please wait...

String Constants

Characters represented with the \ notation can also be used in strings. Strings are enclosed between " " and have an implied null character at the end.

"\aThis text starts with a beep\nand covers two lines"

A string constant cannot be spread over more than one line. However, if the compiler finds two string constants with only spaces or newlines in between it will automatically concatenate the strings together.

The string constants "This is y" "our world!"
or "This is y"

"our world!"

are both equivalents to the single string constant "This is your world!"

Note that a single character is given between ' ' is NOT the same as a string of one character.

'A' is not the same as "A".

A single character in '' can be regarded as a means of expressing a numeric value corresponding to the ASCII value of the character.

'A' is equivalent to '\101' or '\x41' and also 65, 0101 and 0x41