Error C2371: redefinition; different basic types - why?

后端 未结 3 986
一个人的身影
一个人的身影 2021-01-04 03:20

I have the following code:

#include 
#include 

// helping
void sortint(int numbers[], int array_size)
{
  int i, j, temp;

           


        
3条回答
  •  旧巷少年郎
    2021-01-04 03:56

    If you are going to place the function eb after the point at which it is called, then you need to place a prototype for it before it is called... otherwise, C will use the default prototype and then your function ends up redefining it, thus the error you received.

    Alternatively, you can move the functions themselves before they are used in the source file, but that's not always possible. Placing prototypes at the top of the file or, better still, in a header file you can include anywhere you will use the functions is the best alternative.

提交回复
热议问题