Please explain how the following code snippet in C is valid
int main(c, v) char *v; int c;{ //program body }
I came across some examples from the international Obfuscated C code contest, and I'm just curious.
This is a K&R - style function description. See Function Declaration: K & R vs ANSI
However, I do not believe that he has a valid signature for main(), since he vdoes not have the right type. See What are the valid signatures for the C () main () function?
main()
v
This is a pre-ANSI-style function declaration, if you mean why char * v; INT is out of parentheses.
This is "K & R C" in which function arguments are declared between the end of the argument list and the start of the function body.
This is just a definition of a K & R-style function, which, although marked as "obsolete", is still permitted by the standard. What is not so good in this code is that the first parameter should be char **v(or char *v[]) standard.
char **v
char *v[]