Xcode - Warning: Implicit declaration of function is invalid in C99

后端 未结 4 1030
春和景丽
春和景丽 2020-11-27 03:42

Getting a warning : Implicit declaration of function \'Fibonacci\' is invalid in C99. What\'s wrong?

#include 

int main(int argc, const char          


        
4条回答
  •  Happy的楠姐
    2020-11-27 04:05

    The compiler wants to know the function before it can use it

    just declare the function before you call it

    #include 
    
    int Fibonacci(int number); //now the compiler knows, what the signature looks like. this is all it needs for now
    
    int main(int argc, const char * argv[])
    {
        int input;
        printf("Please give me a number : ");
        scanf("%d", &input);
        getchar();
        printf("The fibonacci number of %d is : %d", input, Fibonacci(input)); //!!!
    
    }/* main */
    
    int Fibonacci(int number)
    {
    //…
    

提交回复
热议问题