【发布时间】:2019-11-19 09:46:27
【问题描述】:
我有以下两行,找不到很好的解释
我确实读到了逗号作为运算符和分隔符的双重性质,括号的优先级,以及逗号作为序列点。
int a =(3,4) // here a is 4 because comma here is an operator first a=3 , then a = 4
int a={3,4} // here is the problem , should not a=3 and then a =4 too because comma is a sequence point or it's undefined behavior or what ?
我期待
a=4
a=4 ,
but the actual output is
a=4 , a=3
【问题讨论】:
-
Read the compiler warnings。他们在那里是有原因的。
标签: c comma parentheses curly-braces