日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

c 调用c语言形参为double,C学生作业,’%f’需要’float *’类型的参数,但参数2的类型为’double *’...

發(fā)布時(shí)間:2024/10/14 124 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c 调用c语言形参为double,C学生作业,’%f’需要’float *’类型的参数,但参数2的类型为’double *’... 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

參見英文答案 >

Why does scanf() need “%lf” for doubles, when printf() is okay with just “%f”?????????????????????????????????????5個(gè)

我正在完成一項(xiàng)任務(wù),我收到了這個(gè)警告:

C4_4_44.c:173:2: warning: format ‘%f’ expects argument of type ‘float *’,

but argument 2 has type ‘double *’ [-Wformat]

變量在main中聲明為:

double carpetCost;

我把這個(gè)函數(shù)稱為:

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

這讓我抓狂,因?yàn)檫@本書說你不使用&在

scanf("%f", carpetCost);

從您傳遞它的函數(shù)訪問它時(shí),請(qǐng)參考.

我在這里做錯(cuò)了什么想法?

總結(jié)

以上是生活随笔為你收集整理的c 调用c语言形参为double,C学生作业,’%f’需要’float *’类型的参数,但参数2的类型为’double *’...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。