Skip to main content

Escape Sequences in C Programming

What is an escape sequence

  • An escape sequence is a combination of characters that represents a special character or a combination of special characters.

  • In C, an escape sequence is a combination of the backslash character \ and one or more characters that represent a special character or a combination of special characters.

  • For example, the escape sequence \n represents a newline character, which is used to move the cursor to the beginning of the next line.

  • Similarly, the escape sequence \t represents a tab character, which is used to move the cursor to the next tab stop.

Common escape sequences in C

Following are the common escape sequences in C:

  • \a: Alert (bell) character
  • \b: Backspace character
  • \f: Form feed character
  • \n: Newline character
  • \r: Carriage return character
  • \t: Horizontal tab character
  • \v: Vertical tab character
  • \\: Backslash character
  • \': Single quote character
  • \": Double quote character