C Programming

⌘K
  1. Home
  2. Docs
  3. C Programming
  4. Basic Elements of C
  5. Escape Sequences in C

Escape Sequences in C

Escape sequences in C are special character combinations that start with a backslash () and represent certain non-printable or special characters in string literals or character constants.

  • They allow you to insert characters that are otherwise difficult or impossible to type directly into your source code, such as new lines, tabs, quotes, or special control characters.
image 25

Example:

#include <stdio.h>

int main() {
    printf("Hello, World!\n");      // Prints text followed by a newline
    printf("Column1\tColumn2\tColumn3\n"); // Prints columns separated by tabs
    printf("She said, \"Hello!\"\n"); // Prints quotes inside string
    printf("Backslash: \\\n");        // Prints a backslash
    printf("First Line\rSecond Line\n"); // Carriage return example

    return 0;
}

How can we help?

Leave a Reply

Your email address will not be published. Required fields are marked *