"\n" for new line
"\b" for a backspace, means if u print it, cursor will print and come back 1 character. For example.... cout<<"hello\bHi"; will print "HellHi". because after printing Hello, compiler found a \b escape sequence. so it came 1 character back (at 'o' of Hello) and stat printing Hi from o of Hello..... so u got HellHi instead of HelloHi.
'\r' is used for carriage return to come 1 line back or in start of line.
HOPE I FIXED. MARK THIS THREAD SOLVED AND DO RATE ME
I'm a beginner in C++. I saw \b and \r in a program source code. I've seen \n and I know its purpose. But why do we use \r and \b in C++? Please clear my doubt.
Those codes are called backslash codes (or character escape sequences), there's a quite logical reason for why they exist:
What for example when you want to have a string containing a newline or backspace character? Of course there's no way to input such a character directly via your keyboard (you can't for example just press the backspace key on your keyboard while you're inputting your code in your text-editor because the only thing it will do is erase the character which is to the left of your text cursor), so we use those codes to let the compiler know which character we want. \b and \n are not the only backslash codes supported by C++, there are some more of them, which you can view by clicking this link.
by mvmalderen: add link to full table of supported backslash codes
Post by jonsca and tux4life have divulged all the information related to this topic.But would like to add some from my side.
Apart from the printable characters (character which can be seen on a output screen) we make use of several other operations when working on any text.
When we work on a text editor,the text editor handles all the operations on its own and keeps us away from implementation details.But in C those operations are included in the character set itself so that a user can make use of them and format his/her output in any way required.
These characters which hold a very special meaning and work instead of functions as in text editors are your "Escape Characters".
Every letter has its identity. Say character 'A' instructs the machine to store value of 65 in 1 byte to symbolise 'A'. In escape characters we tell the compiler to escape or neglect the meaning of original character and act differently by placing the '\' symbol before it.Hence the name "Escape Character". You can try something like:
cout << "TestString1__TestString2";
and place '\a' '\b' '\c' ... and so on and test what every character does.