具有空第二个参数的C条件运算符('?') [英] C conditional operator ('?') with empty second parameter
本文介绍了具有空第二个参数的C条件运算符('?')的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
通常是?"运算符以以下形式使用:
Typically the '?' operator is used in the following form:
A ? B : C
但是在B = A的情况下,我看到以下缩写
However in cases where B = A I have seen the following abbreviation
A ? : C
这出奇地有效.最好将第二个参数保留为(样式明智的),还是某些编译器将无法处理此参数?
This surprisingly works. Is it better to leave the second parameter in (style wise), or is their a chance certain compilers won't be able to handle this?
推荐答案
C语言不允许(据我所知),但是gcc之类的编译器将快捷方式a?:c用作扩展名. a?:c
的含义与 a?a:c
相同.
It is not permitted by the language C (as far as I know), but compilers such as gcc have the shortcut a?:c as an extension.
a?:c
means the same as a?a:c
.
这篇关于具有空第二个参数的C条件运算符('?')的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文