Home >>C Tutorial >Escape Sequence in C

Escape Sequence in C

Escape Sequence in C

The sequence of characters that is when used inside string literal or character, it doesn't represent itself is known as the escape sequence in C language.

It is generally composed of two or more characters starting with a backslash \. Here is an example: \n represents a new line.

Here is the list of Escape Sequences in C:

Escape Sequence Meaning
\n New Line
\a Alarm or Beep
\b Backspace
\f Form Feed
\r Carriage Return
\t Tab (Horizontal)
\v Vertical Tab
\" Double Quote
\? Question Mark
\nnn octal number
\xhh hexadecimal number
\\ Backslash
\' Single Quote
\0 Null

Here is an example of escape sequence in C

#include<stdio.h>    
int main()
{    
     int number=50;  
    printf("You\nare\nlearning\n\'c\' language\n\"Let’s learn C language\"");     
return 0;  
}     
Output : You
are
learning
'c' language
"Let’s learn C language"

No Sidebar ads