Escape Sequences in C
Hello everyone, Welcome back to Think & Free. This is the fifth episode of our Express Learning Programming lesson series and today I’m going to talk about How to Use Escape sequences in C. In this series, I will show you how to start programming, step-by-step with the GNU C Programming language. Here are our previous lessons.
Previous Lessons
If you are new to Programming, read our previous lessons before reading this lesson. In this lesson, I will show you what the Escape Sequences mean in C, How escape sequences work, and everything you must know. Okay, Let’s dive into today’s lesson.
Escape Sequences
It is a sequence of characters, They are Configured to other characters or string literal. It can translate into some character. Characters may be difficult or impossible to represent directly.
\a | Alarm or Beep |
\b | Backspace |
\f | Form Feed |
\n | New Line |
\r | Carriage return |
\t | Tab (Horizontal) |
\v | Tab (Vertical) |
\\ | Backslash |
\’ | Single Quote |
\” | Double Quote |
\? | Question Mark |
\ooo | Octal Number |
\xhh | Hexadecimal Number |
\0 | Null |
Let’s see some examples, Here is some example of escape sequences in C.
#includeint main() { printf("Hello\nWorld\n"); printf("\tHello, World\n"); printf("This is \\ backslash"); return 0; }
Open up your favorite text editor and write down these codes, Now save your project and compile it. Once the compilation process has been completed, run the compiled executable file.
I think that’s enough for this quick lesson about Escape sequences. Try yourself, and leave a comment if you have a question.