Escape Sequence in C

Escape sequence in c programming; Through this tutorial, you will learn what is escape sequence and how to use it in c programming.

An escape sequence is a sequence of characters that does not represent itself when used inside a character or string literal, but is translated into another character or a sequence of characters that may be difficult or impossible to represent directly.

List of Escape Sequences in C

Escape SequenceMeaning
\aAlarm or Beep
\bBackspace
\fForm Feed
\nNew Line
\rCarriage Return
\tTab (Horizontal)
\vVertical Tab
\\Backslash
\’Single Quote
\”Double Quote
\?Question Mark
\nnnoctal number
\xhhhexadecimal number
\0Null

Here are some basic examples of escape sequence characters in c; as shown below:

  • \n Escape Sequence
  • \t Escape Sequence
  • \b Escape Sequence
  • \a Escape Sequence

\n Escape Sequence

#include <stdio.h>
int main()
{
printf("Hello \nProgrammer ");
return 0;
}

Output

Hello
Programmer

\t Escape Sequence

#include <stdio.h>
int main()
{
printf("Hello\tProgrammer ");
return 0;
}

Output

Hello        Programmer

\b Escape Sequence

#include <stdio.h>
int main()
{
printf("Hello\b Programmer ");
return 0;
}

Output

Hell Programmer

Note that :- \b will backspace a character.

\a Escape Sequence

#include <stdio.h>
int main()
{
printf("This will make a bell sound\a ");
return 0;
}

Output

This will make a bell sound

Note that :- \a will audio you a bell sound 🔔.

Conclusion

Thus, the article covered in detail about the various escape sequences available in c. Also, the article covered the various escape sequences by explaining some with appropriate examples.

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *