In programming many characters are impossible to represent directly i.e. “enter (or newline)”, “backspace”, “tab” etc. These are the keys or characters which are difficult to print in a string. So now the question is how to represent these characters?

C or C++ as well as many other languages provides a simple solution known as
“escape sequences”. Escape sequences always starts with “\”. They used to represent behavior of certain keys. Below is the table of different escape sequences used in C and C++

Escape SequenceCharacterDescription
\aBell (speaker beeps)Used to make a “beep” sound
\bBackspace (non-erase)Used to move pointer to one character/bit back
\fForm feed/clear screenUsed to tell printer to print on next page
\nNew lineUsed to represent “enter” or print newline
\rCarriage ReturnUsed to move pointer to beginning of same line
\tTabUsed to represent “tab” or print four spaces
\vVertical tabUsed to print four newlines
\\BackslashUsed to represent “\” or print “\”
\?Question markUsed to represent “?” or print “?”
\’Single quoteUsed to represent/print single quote
\”Double quoteUsed to represent/print double quote
\xnnHexadecimal character code nnPrints hexadecimal of any number after “\x” i.e. “\x15”
\onnOctal character code nnPrints octal of any number after “\o” i.e. “\o15”
\nnOctal character code nnPrints octal of any number after “\” i.e. “\15”

Note: These are the standard escape sequences, there are many other escape sequences available that represent different characters.