编译器给出错误:format 指定类型 'float *',但参数的类型'double' [-Wformat]

Compiler giving error: format specifies type 'float *' but the argument has type 'double' [-Wformat]

本文关键字:类型 参数 double -Wformat float format 出错 编译器 错误      更新时间:2023-10-16

我写了一个scanf("%f"), x(x是一个float(。编译器给出标题上的错误。%f%e都给出了相同的结果。

必须使用与号对浮点变量进行寻址,以告知编译器它存储在内存中。

您已完成:

scanf("%f", x); // will obviously throw you a fatal warning

考虑:

scanf("%f", &x); // correct statement

就是这样。