Site icon TestingDocs.com

C Escape Characters

Overview

In this tutorial, we will learn about C Escape characters. In C language, a string is a sequence of characters enclosed between double quotes. There are some limitations on some characters that we put into the string. We use escape characters(also known as escape sequences) to overcome this limitation.

C Escape Characters

The C language supports many escape sequences. The most common escape sequences are as follows::

C Escape Sequence Description
\n New line. This will move the cursor to the new line
\t Tab space, This will print some spaces
\” To escape the double quote character
\’ To escape the single quote character
\\ To display backspace character
\0 Null. This is used to terminate character strings

Example

/**
**********************************
 * Program Description:
  * C Escape Characters Demo
  * Filename: escape.c
  * C Tutorials - www.TestingDocs.com
  *************************************
   */
#include 
int main()
{
    printf("Name in quotes \"TestingDocs\" \nThis is second line\n");
    printf("\tThis will print after tab space \n");
    return 0;
}

Program Output

The program demonstrates the usage of the \n, \t, and \” escape sequences.

C Tutorials

C Programming Tutorials on this website:

https://www.testingdocs.com/c-language-tutorial/

Exit mobile version