A string constant consists of one or more ASCII characters enclosed in single or double quotation marks.

Syntax

' character...'
" character..."

You can specify non-printable characters in string constants using escape sequences. An escape sequence is introduced by the backslash character '\'.

The following escape sequences are supported:

Sequence

Description

\ooo Octal code of character where o is an octal digit
\" Double quotation mark
\' Single quotation mark
\\ Backslash
\b Backspace, ASCII code 8
\f Form feed, ASCII code 12
\n New line, ASCII code 10
\r Carriage return, ASCII code 13
\v Vertical tab, ASCII code 11
\xhh Hexadecimal code of character where h is a hexadecimal digit
Examples

"This is a string constant"
'A string constant with a new line at the end\n'