Escape Sequences in C
What are Escape Characters in C ?
Like every other programming languages, C programming language also has a predefined set of characters, which a programmer can use while coding in C. There are a total of 256 characters in C Language, which are further divided into two categories
- ASCII Characters
- Extended ASCII Characters
Other than these 256 characters, there are some other special characters also present in C, which do not represent themselves, they are categorized as Escape Characters or Escape Sequences in C Programming Language
Difference between ASCII Characters and Escape Sequences in C
Escape Sequences in C are use to represent other characters, which generally are not present in ASCII Characters, and are hard or impossible to represent without using Escape Characters. Escape Characters are usually followed by a ‘backslash‘ and one or more ‘character‘, for example-: \n, \t, etc. As we have discussed above, Escape Characters do not represent themselves, but they are used to represent some other characters or operations. Below is a table which describes about all the Escape Sequences and their use.
Note-: Not all the characters followed by ‘backslash(\)’ will be a Escape Character i.e; if we write
- char str = ‘\c’;
Then, it will not be considered as a Escape Character, and the compiler will throw a error.
List of All the Escape Sequences in C
|Escape Characters||Use for||Hex value in ASCII|
|\f||Formfeed Page break||0C|
|\uhhhh||unicode point below 10,000 hexadecimal||none|
|\uhhhhhhhh||unicode point where h is a hexadecimal||none|
C Code for using Escape Sequences
Get over 200+ course One Subscription
Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others