I have the following code:
#include
#include
// helping
void sortint(int numbers[], int array_size)
{
int i, j, temp;
You call eb
from exera
, before eb
is declared. The compiler assumes it'll return int
then finds an implementation that returns void
further down the file.
The most common fix is to declare your local functions at near top of your file
void eb(int* ptr);
// repeat for each other function which generates the same error
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.
You are trying to call eb
and ec
before they are declared or defined. Move the definition of ec
before eb
and both before exera
. You could also forward declare your functions before you define any of them like so:
void eb(int* ptr) ;
void ec(int* arr, int size) ;