Please explain how the following snippet of code in C is a valid one
int main(c, v) char *v; int c;{
 //program body
}
I stumbled across some examples from the International Obfuscated C code contest and i'm just curious.
Please explain how the following snippet of code in C is a valid one
int main(c, v) char *v; int c;{
 //program body
}
I stumbled across some examples from the International Obfuscated C code contest and i'm just curious.
 
    
     
    
    It's K&R-style function declaration. See Function declaration: K&R vs ANSI
However, I don't believe it has a valid signature for main(), since v isn't of the right type. See What are the valid signatures for C's main() function?
It's the pre-ANSI style of function declaration, if you're referring to why the char*v; int; is outside of the 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's body.
 
    
    That's just the K&R-style function definition, that, although marked "obsolete", is still allowed by the standard. What is not fine in that code is that the first parameter should be char **v (or char *v[]) to be standard.
