ADS

Escape Sequence in C Programming | C Programming

Escape Sequences in C Programming:-

An escape sequence always begins with backward slash and is followed by one or more special characters.
 For example:-
a line feed (LF), which is referred to as new line in C can be represented as \n.

  • Backslash character constants are special characters used in output functions.
  • Although they contain two characters they represent only one character.






Sr.No
Escape Sequence & Description
1
\t
Inserts a tab in the text at this point.
2
\b
Inserts a backspace in the text at this point.
3
\n
Inserts a newline in the text at this point.
4
\r
Inserts a carriage return in the text at this point.
5
\f
Inserts a form feed in the text at this point.
6
\’
Inserts a single quote character in the text at this point.
7
\”
Inserts a double quote character in the text at this point.
8
\\
Inserts a backslash character in the text at this point.

Example

#include
int main() {
   char ch1;
   char ch2;
   char ch3;
   char ch4;
   ch1 = '\t';
   ch2 = '\n';
   printf( "Test for tabspace %c and a newline %c will start here", ch1, ch2);
}

Output

Test for tabspace and a newline
will start here

Post a Comment

0 Comments