【问题标题】:Can anyone explain what is the error in the following program?谁能解释以下程序中的错误是什么?
【发布时间】:2014-08-24 13:16:03
【问题描述】:

谁能解释以下程序中的错误是什么?

#include<stdio.h>
int main()
{
  int a = 10, b = 20;
  (a, b) = 30; // Since b is l-value, this statement is valid in C++, but not in C.
  printf("b = %d", a);
  getchar();
  return 0;
}

【问题讨论】:

  • 你也应该发帖
  • (a, b) = 30; - 为什么要写这个
  • (a, b) --> 20 , (a, b) = 30; --> 20 = 30 不可赋值。
  • 标记为“编译器错误”,但未显示错误消息。为什么?
  • 嗯?为什么要进行这个编辑?不要改变问题!特别是如果它已经有了答案......

标签: c compiler-errors


【解决方案1】:

C 不允许这样的多重赋值,在不同的语句中将每个变量设置为 30。

【讨论】:

  • 或写a = b = 30;
猜你喜欢
  • 1970-01-01
  • 2015-08-13
  • 2018-11-30
  • 2015-08-12
  • 2016-02-02
  • 1970-01-01
  • 2019-06-23
  • 1970-01-01
  • 2021-07-02
相关资源
最近更新 更多