Escape Characters - C Language Basics

C examples for Language Basics:Variable

Introduction

To add new lines into a string the escape character \n is used for representing a line break.

Demo Code

#include <stdio.h>
int main(void) {

   printf("First line\nSecond line");
}

Result

There are several other such characters as seen in the following table.

Character Meaning Character Meaning
\n newline \f form feed
\t horizontal tab \a alert sound
\v vertical tab \' single quote
\b backspace\" double quote
\r carriage return \\ backslash
\0 null character \? question mark
\000octal number (1-3 digits)\xhhhexadecimal number

Related Tutorials