Tuesday, July 16, 2013

Escape Sequences in C

Escape sequences are used mostly in C and C++. It is nothing but a backslash(\) followed by a character. It is meant for doing some function in the output. They are called escape sequences because, backslash makes the C compiler to escape from the normal execution of the string and perform some function.

Here is the list of escape sequences which are generally used in C.


Escape Sequence
Purpose
\a
Bell(beep)
\b
Backspace
\f
Formfeed
\n
New line
\r
Carriage return
\t
Horizontal tab
\v
Vertical tab
\\
Backslash
\’
Single Quotation
\”
Double Quotattion
\ooo
Octal Representation
\xdd
Hexadecimal Representation

Among all the escape sequences, the most commonly used escape sequence is \n and \t.