The ones who are crazy enough to think they can change the world are the ones who do.- Steve Jobs
In C Programming, the word escape sequences means to escape the character from the sequences of words and give special meaning to the escaped character.
Let us consider the following word "hello\nworld". Clearly, n is the character which escapes from the sequences of word, helloworld and a special meaning is given to n i.e) new line.
There are 12 escape sequences in C Programming. They are
Escape Sequence | Use | ASCII Value |
---|---|---|
\n | New Line | 010 |
\t | Horizontal tab | 009 |
\b | Backspace | 008 |
\r | Carriage Return | 013 |
\a | Alert Bell | 007 |
\' | Single quote | 039 |
\" | Double quote | 034 |
\? | Question | 063 |
\\ | Backslash | 092 |
\f | Form feed | 012 |
\v | Vertical tab | 011 |
\0 | Null | 000 |
#include <stdio.h> int main() { printf("Hello \nProgrammer "); return 0; }
Statement followed by \n will be printed in New Line.
#include <stdio.h> int main() { printf("Hello\tProgrammer "); return 0; }
Statement followed by \t will be printed after 8 space.
#include <stdio.h> int main() { printf("Hello\b Programmer "); return 0; }
\b will backspace a character.
#include <stdio.h> int main() { printf("\nab"); printf("\bsi"); printf("\rha"); return 0; }
#include <stdio.h> int main() { printf("This will make a bell sound\a "); return 0; }
\a will audio you a bell sound 🔔.
#include <stdio.h> int main() { printf("\'Hello Programmer\' "); return 0; }
\' will print single quote '.
#include <stdio.h> int main() { printf("\"Hello Programmer\" "); return 0; }
\"\" will print double quote ".
#include <stdio.h> int main() { printf("How are you\? "); return 0; }
\? will print? (Question mark).
#include <stdio.h> int main() { printf("C\\learn\\from\\2braces.com "); return 0; }
\\ will print a single backslash (\).
#include <stdio.h> int main() { printf("\f - female sign. "); return 0; }
\f will print female sign (♀).
#include <stdio.h> int main() { printf("\v - male sign. "); return 0; }
\v will print male sign (♂).
#include <stdio.h> int main() { printf("Hello \0 Programmer "); return 0; }
The statement followed by \0 will not display.
We may make mistakes(spelling, program bug, typing mistake and etc.), So we have this container to collect mistakes. We highly respect your findings.
© Copyright 2019