的C条件运算符(“?”)空第二个参数 [英] C conditional operator ('?') with empty second parameter

查看:127
本文介绍了的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有快捷方式:C为的扩展
A:C 意思是一样的 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屋!

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