warning C4142:benign redefinition of type 求指教,如何改!int numberinput(char *notice){float t;printf(notice);scanf("%f",&t);return t;}在{处出现此问题

来源:学生作业帮助网 编辑:作业帮 时间:2024/03/29 03:53:31
warning C4142:benign redefinition of type 求指教,如何改!int numberinput(char *notice){float t;printf(notice);scanf(

warning C4142:benign redefinition of type 求指教,如何改!int numberinput(char *notice){float t;printf(notice);scanf("%f",&t);return t;}在{处出现此问题
warning C4142:benign redefinition of type 求指教,如何改!
int numberinput(char *notice)
{
float t;
printf(notice);
scanf("%f",&t);
return t;
}
在{处出现此问题

warning C4142:benign redefinition of type 求指教,如何改!int numberinput(char *notice){float t;printf(notice);scanf("%f",&t);return t;}在{处出现此问题
你的函数numberinput()定义的类型是int,但返回的参数t却是float的,类型不匹配; 不是致命错误,编译器会自动类型转换,但可能影响精度,所以给出警告(VC++的编译器吧?).把int换成float即可.