这是我的C程序:
#include<stdio.h>
main()
{
int a,b;
int pow (int,int);
printf("Enter the values of a and b");
scanf("%d %d",&a,&b);
printf("Value of ab is %d",pow(a,b));
}
pow(int c,int d)
{
return c*d;
}
Run Code Online (Sandbox Code Playgroud)
我的程序中没有包含math.h.我正在使用gcc编译器.我收到以下错误
ex22.c:在函数`main'中:
ex22.c:6:错误:`pow'的冲突类型
搜索后我发现math.h中有一个pow函数.但我不包括math.h但我仍然得到错误.怎么样 ?
您不应该为自己的函数使用标识符,该标识符也是C标准库函数的名称,无论您是否包含该标准函数的标头.除非声明了函数static,否则C标准禁止显式,并且编译器可以特别处理这些函数(例如pow(x, 2),通过发出代码x*x而不是函数调用).
| 归档时间: |
|
| 查看次数: |
1102 次 |
| 最近记录: |