条件运算符的中间表达式省略扩展

#include <stdio.h>
int main () {
 int i = 3 ? : 0;
 printf("%d\n", i);
}

这种省略条件运算符中间表达式的写法是GCC特有的扩展语法。上例行为等价于 int i = 3 ? 3 : 0;

我不是鼓吹这种用法,而是以为自己在编辑a.cpp; gcc b.cpp

posted @ 2025-10-19 13:43  华容道专家  阅读(5)  评论(0)    收藏  举报