鱼C论坛

 找回密码
 立即注册
查看: 1731|回复: 4

[已解决]第六节pow运算

[复制链接]
发表于 2020-9-25 11:29:39 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
#include <stdio.h>
int main()
{
        int a;
        int b;
        int c;
        int d;
        int g;
        int f;
       
        a = pow(1,2);
        b = pow(2,3);
        c = pow(3,4);
        d = pow(4,5);
        f = pow(5,6);
        g = a+b+c+d+f;
        printf("结果是%d\n",g);
        return 0;
}
我没有加 #include<math.h>  也可以运行结果也没错 请问#include<math.h>不是必要的吗?
最佳答案
2020-9-25 20:11:22
本帖最后由 风过无痕1989 于 2020-9-25 20:14 编辑

test.c(12) : warning C4013: 'pow' undefined; assuming extern returning int

12行,也就是第1个 pow() 就出现告警了:'pow' 没有定义; 假设extern返回int

我在本板块发了一个《C语言常见错误英中对照及分析》:https://fishc.com.cn/thread-180650-1-1.html

本帖被以下淘专辑推荐:

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2020-9-25 11:58:50 | 显示全部楼层
可能是编译器帮你添了吧。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-9-25 12:18:13 | 显示全部楼层
也没有警告吗?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-9-25 16:37:42 | 显示全部楼层
C:\Users\Administrator\Desktop\C\0925.c        In function 'main':
12        9        C:\Users\Administrator\Desktop\C\0925.c        [Warning] implicit declaration of function 'pow' [-Wimplicit-function-declaration]
12        13        C:\Users\Administrator\Desktop\C\0925.c        [Warning] incompatible implicit declaration of built-in function 'pow'
确实可以运行,不过会提示警告,所以最好还是加上#include<math.h>吧
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-9-25 20:11:22 | 显示全部楼层    本楼为最佳答案   
本帖最后由 风过无痕1989 于 2020-9-25 20:14 编辑

test.c(12) : warning C4013: 'pow' undefined; assuming extern returning int

12行,也就是第1个 pow() 就出现告警了:'pow' 没有定义; 假设extern返回int

我在本板块发了一个《C语言常见错误英中对照及分析》:https://fishc.com.cn/thread-180650-1-1.html
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-6-10 10:46

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表