Escape Sequences

Character Set and Escape Sequences in C

📌 Character Set in C

In the C programming language, the character set consists of 256 characters.

It is broadly divided into:

1️⃣ ASCII character set
2️⃣ Extended ASCII character set

Apart from these, C also includes special characters called escape characters (escape sequences).


📌 Escape Characters (Escape Sequences)

Escape sequences are special character combinations beginning with a backslash \.

They are used to represent:

  • Non-printable characters

  • Formatting characters

  • Special symbols inside strings


📋 List of Escape Sequences in C

Escape SequenceMeaning
\a        Alarm / Beep
\b        Backspace
\f        Form Feed
\n        New Line
\r        Carriage Return
\t            Horizontal Tab
\v        Vertical Tab
\\        Backslash
\'        Single Quote
\"        Double Quote
\?        Question Mark
\ooo        Character with octal value
\xhh        Character with hexadecimal value
\0        Null character

📌 Example Usage

#include <stdio.h> int main() { printf("Hello\nWorld"); printf("\nName:\tJohn"); return 0; }

Output

Hello World Name: John

Comments

Popular posts from this blog

Programming in C GXEST204 - KTU 2024 scheme syllabus notes pdf ------- Dr Binu V P

Structure of a C Program

Single and Multi Dimensional Arrays