Escape Sequence in C Language With Examples
In this series of C language, Today we are going to learn in detail about what is Escape Sequence in C and What is the use of Escape Sequence in C languages.
What is Escape Sequence in C Language
There is some set of characters in C language which we call Character Set or ASCII Code. There is a total of 256 Characters Character Set in C language. The entire Character Set is divided into two parts which are ASCII Character Set and Standard ASCII Character Set. But apart from all this, there are some characters that do not fall into any character set, these are called Escape Sequence.
What is the Meaning of Escape Sequence in C
When we want to start or print a statement from a new line in C language, then we cannot do it just by pressing the Direct Enter key. We need to use Escape Sequence
Let’s understand this with a program.
#include <stdio.h>
int main ()
{
printf ("Welcome To");
printf ("CsTutorialpoint");
return (0);
}
Output -:
Welcome To CsTutorialpoint
In this program, I wanted to print CsTutorialpoint from a new line so I tried to print CsTutorialpoint by writing printf () separately, but CsTutorialpoint did not print from a new line.
Now we print the same line of CsTutorialpoint using Escape Sequence.
#include <stdio.h>
int main ()
{
printf ("Welcome To \n CsTutorialpoint");
return (0);
}
Output -:
Welcome To
CsTutorialpoint
In this program, I wrote Welcome To CsTutorialpoint inside the same printf () and used the “\n” Escape Sequence between Welcome To and CsTutorialpoint, and when I compiled and ran the program, “Welcome To” printed a different line. And “CsTutorialpoint” printed from a different line,
while in the earlier program I wrote both inside different printf (), yet both were printed together in the same line, so obviously using “\n” Escape Sequence We can print a statement in a new line.
By now you have understood that what is Escape Sequence, now let’s learn what is Escape Character.
What is Escape Character
Like I just told by a program in the back that we cannot print the new line by pressing the direct enter key, for that an escape sequence like \n is used, out of this we use the backslash (\) as the “Escape Character”. so backslash (\) is said to be an Escape character.
Escape Sequence consists of a combination of backslash and character. Some important tasks are done in the C language using the Escape character and some other characters.
List of Escape Sequences in C Language
Escape Sequence | Meaning |
\a | Alarm or Beep |
\b | Backspace |
\f | Form Feed |
\n | New Line |
\r | Carriage Return |
\t | Tab (Horizontal) |
\v | Vertical Tab |
\\ | Backslash |
\’ | Single Quote |
\” | Double Quote |
\? | Question Mark |
\nnn | octal number |
\xhh | hexadecimal number |
\0 | Null |
Read More -:
- Data Types in C
- Variable in C
- Format specifier in C
- Type Casting in C
- Compilation Process in C
- Download C Language Notes Pdf
- C Language Tutorial For Beginners
- C Programming Examples With Output
- 250+ C Programs for Practice PDF Free Download
Conclusion
Friends, I hope that you have found the answer of your question and you will not have to search about the Escape Sequence in C Language
However, if you want any information related to this post or related to programming language, computer science, then comment below I will clear your all doubts.
If you want a complete tutorial of C language, then see here C Language Tutorial. Here you will get all the topics of C Programming Tutorial step by step.
Friends, if you liked this post, then definitely share this post with your friends so that they can get information about the Escape Sequence in C Language
To get the information related to Programming Language, Coding, C, C ++, subscribe to our website newsletter. So that you will get information about our upcoming new posts soon.