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
- GeeksforGeeks What is the use of curly brackets in the `var { … } = …` statements ? Destructuring assignment allows us to assign the properties of an array or object to a bunch of variables that are sometimes very convenient and short.
Note: Curly brackets ‘ { }’ are used to destructure the JavaScript Object properties. If we want the variables defined in the object should be assigned to the variables with other names then we can set it using a colon.
The variable declaration indicates that the operating system is going to reserve a piece of memory with that variable name. The syntax for variable declaration is as follows − Here, a, b, c, d are variables. The int, float, double are the data types.
The syntax for variable initialization is as follows − A variable assignment is a process of assigning a value to a variable. A variable may be alphabets, digits, and underscore. A variable name can start with an alphabet, and an underscore but, can’t start with a digit.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With