5.14章节,求大神帮忙改下程序错误顺便交一些从编译器错误反馈中提取程序错误信息的基础技巧
#include <stdio.h>
int taxiFare(km)
{
int distance,float fare;
if(distance<=3)
float fare=14;
else
taxiFare=taxiFare(km-1)+2.3;
return fare=fare*2;
}
int main()
{
int 12kmFare=taxiFare(12);
printf("小明每天打车的总费用为%f元”,12kmFare);
return 0;
}
另附编译器出错提示,能不能帮我说明一下编译器指出的错误有哪些,怎样从编译器的错误报告中自己修改程序错误?
/249/5642/FY7o/hello.c: In function 'taxiFare':
/249/5642/FY7o/hello.c:4:18: error: expected identifier or '(' before 'float'
int distance,float fare;
^
/249/5642/FY7o/hello.c:6:9: error: expected expression before 'float'
float fare=14;
^
/249/5642/FY7o/hello.c:8:17: error: lvalue required as left operand of assignment
taxiFare=taxiFare(km-1)+2.3;
^
/249/5642/FY7o/hello.c:9:16: error: 'fare' undeclared (first use in this function)
return fare=fare*2;
^
/249/5642/FY7o/hello.c:9:16: note: each undeclared identifier is reported only once for each function it appears in
/249/5642/FY7o/hello.c: In function 'main':
/249/5642/FY7o/hello.c:13:9: error: invalid suffix "kmFare" on integer constant
int 12kmFare=taxiFare(12);
^
/249/5642/FY7o/hello.c:13:9: error: expected identifier or '(' before numeric constant
/249/5642/FY7o/hello.c:14:12: warning: missing terminating " character [enabled by default]
printf("小明每天打车的总费用为%f元”,12kmFare);
^
/249/5642/FY7o/hello.c:14:5: error: missing terminating " character
printf("小明每天打车的总费用为%f元”,12kmFare);
^
/249/5642/FY7o/hello.c:15:5: error: expected expression before 'return'
return 0;
^
/249/5642/FY7o/hello.c:16:1: error: expected ';' before '}' token
}
^