我刚刚用c写了一段代码
#include <stdio.h>
int main()
{
int a=0;
option1: a++=5;
option2: ++a=5;
printf("%d\n",a);
return 0;
}
但编译时没有错误
lvalue required as left operand of assignment
为什么会出错? 谢谢!
最佳答案
因为,正如编译器所说,a++
不是左值
,它是右值
。
您将找到有关左值
和右值
here的更多信息.
关于c - 为什么 a++=5 是错误的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28561756/