什么是一个逗号分隔值的列表,括在paranthesis用C是什么意思?一个=(1,2,3); [英] What does a comma separated list of values, enclosed in paranthesis mean in C? a = (1, 2, 3);
本文介绍了什么是一个逗号分隔值的列表,括在paranthesis用C是什么意思?一个=(1,2,3);的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚碰到code,基本上执行以下操作:
I've just come across code that essentially does the following:
int a = (1, 2, 3);
我以前从未见过这种符号。这是什么意思?
I've never seen this notation before. What does it mean?
推荐答案
这是逗号运算:评估 A,b
第一原因 A
来进行评估,然后 b
,结果是,乙
。
This is the comma operator: evaluation of a, b
first causes a
to be evaluated, then b
, and the result is that of b
.
int类型的=(1,2,3);
首先评估 1
,那么 2
,终于 3
,并使用最后 3
来初始化 A
。它是无用这里,但是当,
的左操作数有副作用,它可以是有用的(通常是:当它是一个函数调用)。
int a = (1, 2, 3);
first evaluates 1
, then 2
, finally 3
, and uses that last 3
to initialise a
. It is useless here, but it can be useful when the left operand of ,
has side effects (usually: when it's a function call).
这篇关于什么是一个逗号分隔值的列表,括在paranthesis用C是什么意思?一个=(1,2,3);的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文