C - Strings - Special Characters

Strings can contain special characters that are represented by escape sequences. Escape sequences are combinations of characters that have a special meaning when used within strings. Here are some commonly used escape sequences for special characters in C:

Newline (\n):

It represents a newline character, which moves the cursor to the beginning of the next line.

printf("Hello\nWorld");

Tab (\t):

It represents a tab character, which creates a horizontal tab space.

printf("Name:\tJohn");

Backslash (\\):

It represents a backslash character itself.

printf("The path is C:\\Program Files");

Double Quote (\"):

It represents a double quote character within a string.

printf("She said, \"Hello!\"");

Single Quote (\'):

It represents a single quote character within a character constant or a string.

printf("I don\'t know");