Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Obfuscated Code in C

Tags:

c

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.

like image 854
Bazooka Avatar asked Jan 27 '12 13:01

Bazooka


2 Answers

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?

like image 56
NPE Avatar answered Oct 16 '22 14:10

NPE


It's the pre-ANSI style of function declaration, if you're referring to why the char*v; int; is outside of the parentheses.

like image 31
Roel Avatar answered Oct 16 '22 12:10

Roel