Reputation: 6220
I am reading an article about code obfuscation in C, and one of the examples declares the main function as:
int main(c,v) char *v; int c;{...}
I've never saw something like this, v
and c
are global variables?
The full example is this:
#include <stdio.h>
#define THIS printf(
#define IS "%s\n"
#define OBFUSCATION ,v);
int main(c, v) char *v; int c; {
int a = 0; char f[32];
switch (c) {
case 0:
THIS IS OBFUSCATION
break;
case 34123:
for (a = 0; a < 13; a++) { f[a] = v[a*2+1];};
main(0,f);
break;
default:
main(34123,"@h3eglhl1o. >w%o#rtlwdl!S\0m");
break;
}
}
The article: brandonparker.net (No longer works), but can be found in web.archive.org
Upvotes: 22
Views: 5544
Reputation: 9204
It's the old style function definition
void foo(a,b)
int a;
float b;
{
// body
}
is same as
void foo(int a, float b)
{
// body
}
Your case is same as int main(int c,char *v){...}
But it's not correct.
The correct syntax is : int main(int c, char **v){...}
Or, int main(int c, char *v[]){...}
EDIT : Remember in main()
, v
should be char**
not the char*
as you have written.
I think it's K & R
C style.
Upvotes: 30
Reputation: 23699
It is a pre-ANSI C syntax for function declaration. We don't use it anymore. It is the same as:
int main(int c, char *v)
Upvotes: 7