在C中使用powf()函数时出错

在C中使用powf()函数时出错,c,C,我写这个C代码是为了找到3平方的值 #include <stdio.h> #include <math.h> int main( void ) { float a; a = powf( 3, 2 ); printf( "\n%f\n", a ); return 0; } 如果有帮助,我的gcc版本是4.2.2。问题在于-ansi参数。这相当于-std=c90 如前所述,您需要使用-std=c99在c99中添加。选项相当于-std=c89。

我写这个C代码是为了找到3平方的值

#include <stdio.h>
#include <math.h>
int main( void )
{
    float a;
    a = powf( 3, 2 );
    printf( "\n%f\n", a );
    return 0;
}

如果有帮助,我的gcc版本是4.2.2。

问题在于
-ansi
参数。这相当于
-std=c90

如前所述,您需要使用
-std=c99

在c99中添加。选项相当于
-std=c89
。您需要使用
-std=c99
标志

gcc -o test.exe -std=c99 -Wall test.c -lm
gcc -o test.exe -std=c99 -Wall test.c -lm