I’m beginner. I don’t know why? I’m using Code::Blocks.Please read the following code:




If q=‘ W ‘, it prints out W.
If q=“ W “, it prints out $.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The literal
"W"is not a singlechar, but a null-terminated string consisting of'W'and'\0'.One way to get the desired behaviour by assigning to a
const char*and printing that with%sAs pointed out in comments, you could catch this type of error by increasing your compiler’s warning levels.