明明已经定义了due,为什么还会报警说“使用了未初始化的内存due?”
#include<stdio.h>
main() {
float money,due;
char ontime;
printf("How much do you owe?");
scanf_s("%f", &money);
printf("On time?");
ontime=getchar();
if (ontime == 'y') {
due = money;
}
else if(ontime=='n') {
due = 1.1 * money;
}
printf("You shall pay$%.2f", due);
}
另:这一行说我从double转换到了float,可我全程没有定义过类型为double的变量啊?
due = 1.1 * money;