在 Fedora 20 桌面上使用 GCC 编译,以下代码输出 10。
int x=10;
int y=5;
printf("%d",(y,x));
最佳答案
在 C 语言中,(y,x)
表示计算 x
和 y
并仅返回 x
。例如。来自维基百科:
the comma operator (represented by the token ,) is a binary operator that evaluates its first operand and discards the result, and then evaluates the second operand and returns this value (and type).
关于c - 为什么下面的C代码的输出是10?我的意思是为什么 printf 给出 x 作为输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22280103/