我正在尝试学习一些 C 语言,但我遇到了一个无法解决的问题。看起来很简单,但下面不起作用。
#include <stdio.h>
#include <stdlib.h>
int main() {
printf("%f", pow(4, 3) );
return 0;
}
错误:
Implicitly declaring library function 'pow' with type 'double (double, double)'
我将字符串格式化程序设置为浮动,所以我不确定为什么会看到该错误
答案 0 :(得分:0)
pow()
位于 math.h
头文件中。
应使用 double
的格式说明符。
https://www.programiz.com/c-programming/library-function/math.h/pow
答案 1 :(得分:0)
包含库 #include <math.h>
并将 printf("%f", pow(4, 3) )
行更改为 printf("%lf", pow(4, 3) )
,因为 pow()
返回双倍