为了账号安全,请及时绑定邮箱和手机立即绑定

这是什么鬼?

运行成功 hello.c: In function 'main': hello.c:8:5: warning: implicit declaration of function 'say' [-Wimplicit-function-declaration]     say();     ^~~ test.c: In function 'say': test.c:3:5: warning: implicit declaration of function 'printLine' [-Wimplicit-function-declaration]     printLine(); 什么鬼?

正在回答

3 回答

https://img1.sycdn.imooc.com//5af842f20001a6ba01570150.jpg

hello.c里面第三行extern void printLine()   

test.c里面第二行加

void printLine();

第三行改成static void say()


0 回复 有任何疑惑可以回复我~

在调用外部函数的时候,要先做个调用声明才不会报错。所以hello和test两个文件都需要补充一个函数调用声明。

hello.c

#include <stdio.h>

extern void say();

void printLine()     //这里定义的方法对吗?

{

   printf("**************\n");   

}

int main()

{

    say();

    return 0;

}



test.c

#include <stdio.h>

extern void printLine();

void say(){

    printLine();

    printf("I love imooc\n");

    printf("good good study!\n");

    printf("day day up!\n");

    printLine();

}


2 回复 有任何疑惑可以回复我~

你写的test.c那个文件没有定义头文件,然后有mian函数的文件里没有调用test的头文件

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
C语言入门
  • 参与学习       926460    人
  • 解答问题       20800    个

C语言入门视频教程,带你进入编程世界的必修课-C语言

进入课程

这是什么鬼?

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号