C中赋值表达式的结果是什么?

use*_*316 12 c expression assignment-operator

在以下代码中:

int c;
while((c=10)>0)
Run Code Online (Sandbox Code Playgroud)

什么是c = 10评价什么?是1表示值10成功分配给变量c,还是10?为什么?

Bat*_*eba 14

c = 10是表达式返回10,其也将10分配给c.

  • @ user2131316:*表达式*`c = 10`在赋值后具有值'c`([N1570](http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570 .pdf),6.5.15/3).赋值表达式不是布尔表达式. (3认同)

Gur*_*ity 9

据说在C99 6.5.16

An assignment operator stores a value in the object designated by the left operand. An        
assignment expression has the value of the left operand after the assignment, but is not an 
lvalue.
Run Code Online (Sandbox Code Playgroud)