0

Why compiler in C++ ignores first backslash (\) in output ?

The code cout<<"\abc"; //output is abc The code cout <<"\\pqr" //output is \pqr The code cout <<"\ijk\+" //output is ijk+ Why this happens? It ignores the appearing of a single backslash (\) at any line in a output. Can I get a solution to this

27th Dec 2016, 10:55 AM
Prateek Mahajan
Prateek Mahajan - avatar
2 ответов
+ 1
backslash is used to escape some special characters that have special meanings to the compiler like ", &, ? etc. to use these characters in output we have to use the backslash, then compiler ignores character that is follwed by backslash \ e.g cout<<"hi my name is rk & i am a developer "; this statement will produce compilation error. corrected code: cout<<" hi my name is rk \& i am a developer";
27th Dec 2016, 11:04 AM
Ravi Kumar
Ravi Kumar - avatar
0
Thanks a lot for the answer
27th Dec 2016, 1:59 PM
Prateek Mahajan
Prateek Mahajan - avatar