【发布时间】:2017-09-19 13:23:02
【问题描述】:
标题描述了我正在尝试做的事情,但我收到了我从未声明过 base1 的错误消息。我实际上知道这一点,但我不确定如何真正解决这个问题。
int getBase1(void);
int setBase1(double);
int main(void){
getBase1();
setBase1(base1);
}
int getBase1(void){
printf("Please enter the length of a base: ");
return;
}
int setBase1(double base1){
scanf("%lf", &base1);
}
【问题讨论】:
-
编译告诉你
base1名称没有定义在main的范围内,这是完全正确的。您可能想详细说明您想要实现的目标。 -
为什么不传递变量的引用? scanf 将为该引用设置值。
-
@DivyaMamgai C 中没有引用。
-
因为 base1 没有定义
-
@DivyaMamgai 如果你的意思是“指针”,那么你应该写“指针”。在 C 中,您不能像在 C++ 中那样通过引用传递变量。
标签: c printf scanf getter-setter