的转义序列?在 c++

发布于 2024-08-08 08:19:12 字数 85 浏览 3 评论 0原文

我正在查看 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初见你 2024-08-15 08:19:12

这是为了防止问号被误解为三字母组的一部分。

例如,在

"What??!"

“??!”中,将被解释为 | 字符。因此,您必须按如下方式转义问号:

"What\?\?!"

http://msdn.microsoft.com/en-us/library/bt0y4awe%28VS.80%29。 ASPX

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文