Escape Sequences

Escape sequences are special symbols prefixed with a back slash ( \ ). These symbols can be used in printf() function to provide a formatted output. Sometimes they are used in formatted input too.







Here is the list of escape sequences:

Escape Sequence Description
\b Moves the cursor back one position (non-destructive).
\n Moves the cursor to the first position of the next line.
\r Moves the cursor to the first position of the current line
\t Moves the cursor to the next horizontal tabular position.
\’ Produces a single quote
\” Produces a double quote
\\ Produces a single backslash

Example

int main()
{
int a=3,b=56;
printf(“%d\n%d”,a,b);
getch();
return(0);
}

Output
3
56

Escape Sequences
Tagged on: