+ 2
What is output and why????
Q1 Cout<<"\\"; a ) \ b )\\ Q2 cout<<"\"; a ) \ b) error
4 ответов
+ 5
Inside a quoted string, the backslash character is used as a delimiter to start an escape sequence which consists of the backslash character itself and an additional character.
This means that if you want to print the backslash character, you have to escape it itself, which is what is happening in Q1. Here, the first '\' starts the escape sequence, and then the second '\' is actually embedded in the string, resulting in output a).
Otherwise, the next character belongs to the sequence, which in Q2 is ". You use the sequence \" to print the quote character which otherwise would end the string. However, now that the second " is escaped, it no longer terminates the string, resulting in an error due to a missing double quote.
+ 4
q1 a q2 error since \ it is pecial symbol to specify \n enter \t tab and etc . and if you want use this aymbol as char literal you need to ad \\.
+ 1
Q1-A
Q2-B