C Escape Sequences

C Escape Sequences

Within a string or character literal these sequences can be used to insert special characters. They are all prefixed with a backslash.

Alert

ASCII 7; causes an alert/bell but does not change the output position.

1
'\a'

Backspace

ASCII 8; moves the output position left.

1
'\b'

Form Feed

ASCII 12; moves the output position to the start of the next page.

1
'\f'

New Line

ASCII 10; moves the output position to the start of the next line.

1
'\n'

Carriage Return

ASCII 13; moves the output position to the start of the current line.

1
'\r'

Vertical Tab

ASCII 11; moves the output position to the next vertical tab.

1
'\v'

Tab

ASCII 9; moves the output position to the next horizontal tab.

1
'\t'

Single Quote

ASCII 39; outputs a single quote.

1
'\''

Double Quote

ASCII 34; outputs a double quote.

1
'\"'

Question Mark

ASCII 63; outputs a question mark.

1
'\?'

Backslash

ASCII 92; outputs a backslash.

1
'\\'

Octal Characters

Outputs the character given by the octal digits. There may be up to 3 digits.

1
'\nnn'

Hexadecimal Characters

Outputs the character given by the 2 hexadecimal digits.

1
'\xhh'

Unicode Characters

Outputs the character given by the 4 hexadecimal digits.

1
'\uhhhh'

Outputs the character given by the 8 hexadecimal digits.

1
'\Uhhhhhhhh'

Edited by nakst on Reason: Initial post