Escape Sequence in C Programming is useful to format the output. The general and most commonly used escape character is \n (to generate a Newline).
The list of available escape sequences in this programming language.
Escape Sequence | Operation |
---|---|
\a | Alarm or Beep |
\b | Backspace |
\f | Form Feed |
\n | New Line |
\r | Carriage Return |
\t | Horizontal Tab |
\v | Vertical Tab |
\\ | Backslash |
\’ | Single Quote |
\” | Double Quotes |
\? | Question Mark |
\nnn | Octal Number |
\xhh | Hexadecimal Number |
\0 | NULL |
Escape Sequence in C Programming Example
In this program, we are using some of the escape sequence characters inside the printf statement. Through this, we can show their functionality and how to use them in C Programming.
#include<stdio.h> int main() { // Horizontal Tab printf("Tutorial\tGateway \n"); //New Line printf("Welcome To \nTutorial Gateway \n"); // Single Quote, and Question Mark printf("Learn \'C\' Programming\? \v Visit Tutorial Gateway \n"); // Vertical Tab printf("\v"); // Double Quotes printf("\"Tutorial Gateway\" "); // Carriage Return printf("\r"); return 0; }