简体   繁体   中英

Escape sequence for ? in c++

I was looking at the escape sequences for characters in strings in c++ and I noticed there is an escape sequence for a question mark. Can someone tell me why this is? It just seems a little odd and I can't figure out what ? does in a string. Thanks.

It's to keep a question mark from getting misinterpreted as part of a trigraph .

For example, in

"What??!"

The "??! would be interpreted as the | character. So, you have to escape the question marks as follows:

"What\?\?!"

Example complements of http://msdn.microsoft.com/en-us/library/bt0y4awe%28VS.80%29.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM