What is Escape Character.?

C language come with some escape characters. Escape characters are used for perform the some specific task in program. All escape characters are constant in C language. In C language we have various type of escape character's that are given below in the table.

Table of Escape Character's

Escape Character's Description Output
\" To print the double quote symbol. "
\' To print the single quote symbol. '
\n Cursor will jump to next line.  
\b Cursor will go one step back.  
\t If you want to give 5 time space. Called as a tab space.  
\r Carriage return. Cursor will go start of the string.  
\\ To print the forward slash symbol. \
\\\\ To print the double forward slash symbol. \\

We use forward slash (\) symbol to display the special symbols on the screen. Like if you want to display double quote (") symbol on the screen. Without forward slash C program will not allow to you display the double quote (") symbol. It will give you error.

Here forward (\) slash mean nothing but remove the first symbol and display the rest thing. We always use forward Slash (\) symbol to print the escape characters.

Example of Escape Character's:

Statement 1.

    printf(" \" ");

Output:

	"

In statement 1 you will see the double quote (") symbol. Without forward slash (\) you can't print the double quote (") symbol.

Statement 2.

    printf(" \' ");

Output:

	'

In statement 2 you will see the Single quote (') symbol. Without forward Slash (\) you can't print the Single quote (') symbol.

Statement 3.

    printf(" \"\" ");

Output:

	" "

In statement 3 you will see the two double quote's (") symbol. To print the two double quote's symbol we use two forward slash (\) symbol with every double quote symbols.

Statement 4.

    printf(" Hello \t Programmer ");

Output:

	Hello 	Programmer

In statement 4 you will see the space in between two characters. That come with help of (\t) tab space escape character. It use for tab space and you also called it tab space.

Every single forward slash (\) symbol use to print the only single escape characters. If you want to print multiple escape characters then use multiple forward slash (\) symbol with every escape characters.

You can understand more by doing practice itself.

Advertisement here

Share this Page.

Post Your Comment