第27行返回错误(以“费用”开头的行)说明“未声明的引用(对于calculateCharge,我的最佳猜测)”和编译器说明“ld返回1退出状态” 我不能为我的生活得到需要改变的东西。
float calculateCharge(float);
int main()
{
printf("Hello world!\n");
int car;
int num_cars;
float total_charges = 0;
float total_hours = 0;
printf("How many cars?\n\n"); //prompt
scanf("%d", &num_cars); //prompt
float hours [num_cars + 1]; //declaring parallel arrays
float charges [num_cars + 1];
for (car=1; car<=num_cars; car++)
{
printf("How many hours for car #%d?", car); //prompt
scanf("%f", &hours[car]); //input hours
charges [car] = calculateCharge(hours [car]);
total_charges = total_charges + charges [car];
total_hours = total_hours + hours [car];
}
printf("%s\t%s\t%s\t", "Car", "Hours", "Charge");
for (car = 1; car <=num_cars; car++)
{
printf("\n%d\t%.2f\t%.2f\n", car, hours[car], charges[car]);
}
printf("\n%s\t%.2f\t%.2f\n", "Total", total_hours, total_charges);
return 0;
}
答案 0 :(得分:3)
假设这是您的整个代码,您已经提供了calculateCharge
签名的前向声明,因此编译器可以生成代码来调用它(一旦它知道实际定义在哪里) ,但你还没有提供实际的定义。