c 调用c语言形参为double,c学生作业,’%f’需要’float *’类型的参数,但参数2的类型为’double *’... -ag凯发k8国际
参见英文答案 >
why does scanf() need “%lf” for doubles, when printf() is okay with just “%f”? 5个
我正在完成一项任务,我收到了这个警告:
c4_4_44.c:173:2: warning: format ‘%f’ expects argument of type ‘float *’,
but argument 2 has type ‘double *’ [-wformat]
变量在main中声明为:
double carpetcost;
我把这个函数称为:
getdata(&length, &width, &discount, &carpetcost);
这是功能:
void getdata(int *length, int *width, int *discount, double *carpetcost)
{
// get length and width of room, discount % and carpetcost as input
printf("length of room (feet)? ");
scanf("%d", length);
printf("width of room (feet)? ");
scanf("%d", width);
printf("customer discount (percent)? ");
scanf("%d", discount);
printf("cost per square foot (xxx.xx)? ");
scanf("%f", carpetcost);
return;
} // end getdata
这让我抓狂,因为这本书说你不使用&在
scanf("%f", carpetcost);
从您传递它的函数访问它时,请参考.
我在这里做错了什么想法?
总结
以上是ag凯发k8国际为你收集整理的c 调用c语言形参为double,c学生作业,’%f’需要’float *’类型的参数,但参数2的类型为’double *’...的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇:
- 下一篇: