What is Escape sequence...?
Escape sequence characters
Q) What is the escape sequence? What is its purpose? Explain the meaning of the following?
- \b
- \r
- \f
- \n
- C supports a special type of character which is the combination of backslash (/)and another character e.g. in is known as escape sequence character.
- The \ is considered as an escape character. This causes an escape from some normal interpretation about a string so that the next character means recognized essentially one having a special meaning.
Following are the escape sequence characters in C with their meanings:
![]() |
Image Source ~ Crafted With ©Ishwaranand - 2020 ~ Image by ©Ishwaranand |
Character meaning Escape sequence
\a - Audible alert (beep)
\b - Backspace
\n - New line
\t - Horizontal tab
\f - Form feed
\r - Carriage return
\\ - Backslash
\' - single quote
\" - Double quote
\v - Vertical tab
\? - Question mark
\O - Null character
- \a
It gives an audible beep.
printf("\a")
- \b
This character works as backspace.
printf ("abcd\b");
printf ("xyz");
output:
abcxyz
- \n
It display the new line on screen
printf("abcd\nxyz");
output:
abcd
xyz
- \t
It display the horizontal tab.
printf("abcd\txyz");
output:
abcd xyz
- \f
This character works as a form feed.
- \r
This character works as a carriage return.
printf("abc\rxyz");
output:
xyz