ABA
@ABA (A)

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

コンパイラ時の警告

Q&A

コンパイラ時に次の警告が出ます。
対処できず困っております。何かわかりましたら教えていただけたらと思います。

ample_02_02.c: In function 'scan_double':
sample_02_02.c:6:5: warning: format '%f' expects argument of type 'float *', but argument 2 has type 'double *' [-Wformat=]

include

double scan_double (void) {
double d;

scanf("%1f",&d);

return d;

}

double calc_weight(double h) {
double sw;

h = h/100.0;
sw = h*h*22.0;

return sw;

}

void print_message(double w, double sw) {
double df;

df = w - sw;
if (df < -10)      printf("underweight\n");
else if (df <= 10) printf("normal\n");
else               printf("overweight\n");

}

int main(void) {
double h, sw, w;

h = scan_double();
w = scan_double();

sw = calc_weight(h);
print_message(w, sw);

return 0;

}

0

1Answer

解決いたしました。
scanf("%1f",&d);ではなく scanf("%lf",&d); でした。

1Like

Your answer might help someone💌