Miscellaneous › Others › C program without writting main() function › Hi Monika, Interesting
Hi Monika,
Interesting question.
There is actually a main() there in your code.
Try to understand the meaning of the following macros.
#define decode(s,o,l,v,i,n,g)v##s##l##o
A function named ‘decode’ with 1st argument ‘s’, second argument ‘o’, third argument ‘l’ and so on, is defined as nothing but a ‘string’, formed by concatinating the following arguments in the order,
v – 4th argument
s – 1st argument
l – 3rd argument
0 – 2nd argumnet
Now this function is called by another function named ‘start’ which is defined as below.
#define start decode(a,n,i,m,a,l,s)
A function named ‘start’ with no arguments, is defined as making a fucntion call to the already defined function ‘decode’ along with passing value to 1st argument as ‘a’, 2nd argument as ‘n’ and so on.
Now the working! On this function call the function ‘decode’ receives the argument values as follows
No. argument value received
1 s a
2 o n
3 l i
4 v m
5 i a
6 n l
7 g s
Now what the ‘decode’ function is defined as?
It forms a string by concatinating the values of arguments in the order v, s, l, o
argument value concatenation process
v m m
s a ma
l i mai
o n main
You see how the main is made??
Simply, the function ‘start’ is defined as making a function call to decode which is alredy defined as generating a string ‘main’ on that function call from start.
Hence ‘start’ is indeirectly defined as ‘main’
It is like writing the following statement
#define start main
I hope this ‘animal’ has helped you in ‘solving’ your question much better than people from other forums do!!
You can concentrate on forums based on programming questions only. Since your questions will be answered by people who have spend major part of their life in programming, they will consider these kind of questions as silly once and you won’t get an explanation like the one I’ve given you on your question.
So I suggest you to try the people on other general technical forums like engineers garage’s before bothering experts on programming questions based forums.