【发布时间】:2013-08-21 04:14:49
【问题描述】:
#include <stdio.h>
int main()
{
int a = 1, b;
a ? b = 3 : b = 4;
printf("%d, %d", a, b);
return 0;
}
[user@localhost programs]$ gcc -Wall vol.c
vol.c: In function ‘main’:
vol.c:5:16: error: lvalue required as left operand of assignment
a ? b = 3 : b = 4;
^
我已将左值设为b,那么为什么gcc 显示错误以及如何解决?
【问题讨论】:
标签: c++ c gcc compiler-errors conditional-operator