是什么???????!运算符在C中执行? [英] What does the ??!??! operator do in C?

查看:158
本文介绍了是什么???????!运算符在C中执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到了一行C,看起来像这样:

I saw a line of C that looked like this:

!ErrorHasOccured() ??!??! HandleError();

它已正确编译,并且运行正常.似乎正在检查是否已发生错误,如果已发生,则将其处理.但是我不太确定它到底在做什么或如何做.看起来程序员似乎正在尝试表达他们对错误的感受.

It compiled correctly and seems to run ok. It seems like it's checking if an error has occurred, and if it has, it handles it. But I'm not really sure what it's actually doing or how it's doing it. It does look like the programmer is trying express their feelings about errors.

我以前从未用任何编程语言见过过??!??!,而且在任何地方都找不到它的文档. (Google对诸如??!??!之类的搜索词没有帮助).它是做什么的,代码示例如何工作?

I have never seen the ??!??! before in any programming language, and I can't find documentation for it anywhere. (Google doesn't help with search terms like ??!??!). What does it do and how does the code sample work?

推荐答案

??! trigraph 转换为|.它说:

!ErrorHasOccured() || HandleError();

,由于短路,它等效于:

which, due to short circuiting, is equivalent to:

if (ErrorHasOccured())
    HandleError();

本周大师(与C ++交易,但此处相关),我在这里选择这个.

Guru of the Week (deals with C++ but relevant here), where I picked this up.

三字组合的可能起源或@DwB在评论中指出,这很有可能是因为EBCDIC很难(再次).在IBM developerWorks董事会上的讨论似乎支持了这一理论.

Possible origin of trigraphs or as @DwB points out in the comments it's more likely due to EBCDIC being difficult (again). This discussion on the IBM developerworks board seems to support that theory.

根据ISO/IEC 9899:1999§5.2.1.1,脚注12(h/t @ Random832):

From ISO/IEC 9899:1999 §5.2.1.1, footnote 12 (h/t @Random832):

三字母组合序列使您可以输入在不变代码集中未定义为的字符 在ISO/IEC 646中进行了描述,它是七位美国ASCII代码集的子集.

The trigraph sequences enable the input of characters that are not defined in the Invariant Code Set as described in ISO/IEC 646, which is a subset of the seven-bit US ASCII code set.

这篇关于是什么???????!运算符在C中执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆