Obfuscated code in C

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.

+5
source share
4 answers

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?

+9
source

This is a pre-ANSI-style function declaration, if you mean why char * v; INT is out of parentheses.

+2
source

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.

0
source

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.

0
source

All Articles