Escape sequence in C explanation with example

Escape sequence in C:

Escape sequence is a sequence of characters those are used for any other characters or sequence of characters which are hard to display directly in a string. In C, each escape sequence starts with a backslash \ and consists of one or more characters after this. This backslash is called escape character.

For example,\b is used for backspace and \n is used for new line. Without these escape sequences, it won’t be possible to add them in a string.

Escape sequences in C:

Following escape sequences are defined in C:

Escape sequence Description
\b Used for backspace
\e Escape character
\a Used to play an alert like beep, bell
\f Formfeed
\n newline
\r carriage return
\v vertical tab
\t horizontal tab
\ backslash
single quotation mark
double quotation mark
? question mark

How to use escape sequence in C program:

We can put an escape sequence in anywhere in a string in C and it will be translated. For example:

#include <stdio.h>

int main()
    return 0;

It will print:


By adding the escape character \n, we added one newline in between the words.

escape sequence in c

You might also like:

Where is the color and why codevscolor ?

Long story short, I love paintings and I paint on weekends. We(me and my wife) have one Youtube channel. Below is a video that I did recently. If you love this please do subscribe to support us 😊