这是什么鬼?

来源:5-13 内部函数与外部函数

树34

2018-04-19 10:41

运行成功 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回答

  • 慕粉4209211
    2018-05-13 21:53:45

    https://img.mukewang.com/5af842f20001a6ba01570150.jpg

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

    test.c里面第二行加

    void printLine();

    第三行改成static void say()


  • 智仝障
    2018-04-19 13:38:30

    在调用外部函数的时候,要先做个调用声明才不会报错。所以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();

    }


  • qq_珍爱只如梅_0
    2018-04-19 13:37:26

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

C语言入门

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

926460 学习 · 20800 问题

查看课程

相似问题