Curriculum
Course: C basic
Login

Curriculum

C basic

C Introduction

0/1

C Get Started

0/1

C Comments

0/1

C Constants

0/1

C Operators

0/1

C Break and Continue

0/1

C User Input

0/1

C Memory Address

0/1

C Structures

0/1
Text lesson

Special Characters

Strings – Special Characters

Due to the necessity of enclosing strings within quotes, this particular string may lead to misinterpretation by C, resulting in an error.

char txt[] = “We are the so-called “Vikings” from the north.”;

To circumvent this issue, one solution is to utilize the backslash escape character.

This ( \ ) converts special characters into string characters.

 

Escape character

Result

Description

\’

Single quote

\”

Double quote

\\

\

Backslash

The sequence \” within a string inserts a double quote character:

Example

char txt[] = “We are the so-called \”Vikings\” from the north.”;

The sequence \’ within a string inserts a single quote character:

Example

char txt[] = “It\’s alright.”;

The sequence \\ within a string inserts a single backslash character:

Example

char txt[] = “The character \\ is called backslash.”;

Additional commonly used escape characters in C include:

Escape Character

Result

\n

New Line

\t

Tab

\0

Null