<分区>
我正在做作业,我收到了这个警告:
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);
当从传递它的函数访问它时,它是引用。
知道我在这里做错了什么吗?