C Special Characters

In C, special characters are characters that have a special meaning or function. These characters are represented by escape sequences that begin with a backslash ().

Some common special characters in C are:

  • \n: Used for a new line.
  • \t: Used for a tab.
  • \r: Used for a carriage return.
  • \b: Used for a backspace.
  • \f: Used for a form feed.
  • ‘: Used for a single quote.
  • “: Used for a double quote.

Example:

#include <stdio.h>

int main() {
   printf("Hello\tWorld!\n");
   printf("This is a\b test.\n");
   printf("C:\\Windows\\System32\n");
   printf("He said, \"Hello World!\"\n");
   printf("She said, 'Hi!'\n");
   printf("It's a beautiful day.\n");
   
   return 0;
}

This program will display the following output:

Hello   World!
This is a test.
C:\Windows\System32
He said, "Hello World!"
She said, 'Hi!'
It's a beautiful day.

Special characters are used to control the formatting and display of text in a program. They can be used to add whitespace, create tables, and generate formatted output, among other things.

Wordpress Social Share Plugin powered by Ultimatelysocial
Wordpress Social Share Plugin powered by Ultimatelysocial