The C escape sequences program example



Compiler: Visual C++ Express Edition 2005

Compiled on Platform: Windows XP Pro SP2

Header file: Standard

Additional library: none/default

Additional project setting: Set project to be compiled as C

Project -> your_project_name Properties -> Configuration Properties -> C/C++ -> Advanced -> Compiled As: Compiled as C Code (/TC)

Other info: none

To do: Using all the C escape sequences in program to see the result or the purpose of the escape sequences

To show: How to use the C escape sequences in C programming




/* Testing the escape sequences */

#include <stdio.h>


int main(void)


printf("Testing the escape sequences:\n");



/* 3 times audible tone */

printf("The audible bell ---> \\a \a\a\a\n");

printf("The backspace ---> \\b___ \bTesting\n");


/* printer must be attached...*/

printf("The formfeed, printer ---> \\f \fTest\n");

printf("The newline ---> \\n \n\n");

printf("The carriage return ---> \\r \rTesting\r\n");

printf("The horizontal tab ---> \\t \tTesting\t\n");

printf("The vertical tab ---> \\v Testing\v\n");

printf("The backslash ---> \\ \\Testing\\\n");

printf("The single quote ---> \' \'Testing\'\'\'\n");

printf("The double quote ---> \" \"Testing\"\"\n");

printf("Some might not work isn't it?\n");


return 0;



Output example:


Testing the escape sequences:


The audible bell ---> \a

The backspace ---> \b___Testing

The formfeed, printer ---> \f ?Test

The newline ---> \n

Testingriage return ---> \r

The horizontal tab ---> \t Testing

The vertical tab ---> \v Testing?

The backslash ---> \ \Testing\

The single quote ---> ' 'Testing' ' '

The double quote ---> " "Testing""

Some might not work isn't it?

Press any key to continue . . .



C and C++ Programming Resources | C & C++ Code Example Index