For the following C code (for swapping two numbers) I am getting the \"conflicting types\" error for swap
function:
#include
#includ
You failed to declare your swap
explicitly, forcing the compiler to make assumptions about the function at the point of the call. The compiler, in accordance with C rules, will assume that swap
is
int swap(int *, int *, size_t)
Later you declare your swap as
void swap(void *, void *, int)
which is obviously different from what the compiler assumed. This is the conflict the compiler is telling you about.
Also, your void swap
attempts to return 0
. What were you trying to achieve by that?
P.S. It's int main
, not void main
.
P.P.S. The program is not guaranteed to produce any output if its output does not end in a new-line character.