I've just come across someone's C code that I'm confused as to why it is compiling. There are two points I don't understand.
-
The function prototype has no parameters compared to the actual function definition.
-
The parameter in the function definition does not have a type.
#include <stdio.h>
int func();
int func(param)
{
return param;
}
int main()
{
int bla = func(10);
printf("%d", bla);
}
Why does this work?
I have tested it in a couple of compilers, and it works fine.
Best Answer
All the other answers are correct, but just for completion
And again for the sake of completeness. From C11 specification 6:11:6 (page: 179)