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
2 Answers
+ 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";
0
Thanks a lot for the answer