Implicit declaration of function 'sum' is invalid in C99

前端 未结 2 1831
忘掉有多难
忘掉有多难 2020-12-20 23:33

I\'ve been looking for a solution to this but haven\'t found anything that will help. I\'m getting the following errors:

Implicit declaration of function \'s         


        
相关标签:
2条回答
  • 2020-12-21 00:01

    The problem is that by the time the compiler sees the code where you use sum it doesn`t know of any symbol with that name. You can forward declare it to fix the problem.

    int sum (int values[], int count);
    

    Put that before main(). This way, when the compiler sees the first use of sum it knows that it exists and must be implemented somewhere else. If it isn't then it will give a liner error.

    0 讨论(0)
  • 2020-12-21 00:02

    You need to add declaration for these two functions, or move the two function definitions before main.

    0 讨论(0)
提交回复
热议问题