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

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including 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. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

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