【发布时间】:2017-08-12 15:58:57
【问题描述】:
我正在编写一个假设打印出程序执行描述的函数。我的程序中的一个函数使用0 作为基数为 10 的数字转换的信号。
我希望我的程序有友好的输出,并告诉用户一个数字是否已转换为以 10 为底,而不是让程序说该数字是从以 0 为基础的转换。
当我尝试编译此代码时,我收到一条错误消息,上面写着“表达式不可分配”。
我正在使用 cc 编译器在命令行上编译
Apple LLVM 版本 7.3.0 (clang-703.0.29)
知道这个错误是什么意思以及如何纠正吗? 谢谢。
void foo( int base ){
int theBase;
base == 0 ? theBase = 10: theBase = base;
printf("%s%d\n", "The base is ", theBase)
}
错误信息:
error: expression is not assignable
base == 0 ? theBase = 10: theBase = base;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
【问题讨论】:
-
如果一个解决方案对您来说足够好,请将其标记为结束您问题的最佳答案。
标签: c compiler-errors expression variable-assignment cc