How To Send an Escape Sequence in C Programming

The Escape Sequences are special characters for formatting; they can be recognized in the code by their characteristic backslash followed by any character that does a certain purpose. These special printing characters are used to make the output readable when printing characters to the screen, file, or other device (such as printer). Below are examples of implementation using escape sequences in C: 

Escape sequences in printing to the screen. This example code will show you a program using escape sequence newline ('\n') to separate between two sentences.

The code:
#include <stdio.h>
int main()
printf("After the end of this line, the next output will begin in a newline.\n");
printf("Hi, im start at a newline.");
return 0;

  • The above code is a simple, straight example of implementation using escape sequence newline. This special character is a character backslash followed by the character letter n ('\n') and it's used to make a line feed (LF) which in C is a newline.
  • The program will output the code as follows:

After the end of this line, the next output will begin in a newline.
Hi, im start at a newline.

Escape sequences in the file. The example code will show you how escape sequence newline ('\n') and quotation mark ('\"') work in the file.

The code:
#include <stdio.h>

int main()
FILE *fpoint;

fpoint = fopen("test.dat", "w");

fprintf(fpoint, "after the end of this line, it will make a new line on the file.\n");

fprintf(fpoint, "Hey, im start at newline on this file. \n");

fprintf(fpoint,"Bonus : \"this is quotation marks\". ");


return 0;

  • The code above is a program using a simple file handling in C to write string characters to a file.
  • Each sentence that write in the file will end with a escape sequence newline ('\n') and also quotation mark ('\"'). The output to the file is as follows:

after the end of this line, it will make a new line on the file.
Hey, im start at newline on this file. Bonus : "this is quotation marks".

Here is a the list of escape sequence in C. You can experiment with the examples above. Youl'll be needing these when programming C in text format, so get to know a few of them.

  1. Character for Bell (Alert) is '\a'.
  2. Character for Backspace is '\b'.
  3. Character for Horizontal Tab is '\t'.
  4. Character for Vertical Tab is '\v'.
  5. Character for Newline (Line Feed) is '\n'.
  6. Character for Form Feed is '\f'.
  7. Character for Carriage Return is '\r'.
  8. Character for Quotation Mark is '\"'.
  9. Character for Apostrophe is '\''.
  10. Character for Question Mark is '\?'.
  11. Character for Backslash is '\\'.
  12. Character for Null is '\0'.


Share this article!

Follow us!

Find more helpful articles: