Create C program without main

I am  using a preprocessor directive called #define with arguments to give an impression that the program runs without the main function. 

The ‘##‘ operator is called the token pasting or token merging operator. That is, we can merge two or more characters with it. 

#define decode(s,t,u,m,p,e,d) m##s##u##t

decode(s,t,u,m,p,e,d) is being expanded as “msut” (The ## operator merges m, s, u and t into msut). The logic is, when you pass (s,t,u,m,p,e,d) as argument it merges the 4th, 1st, 3rd and the 2nd characters (tokens).

Now, look at the third line of the program:

#define begin decode(a,n,i,m,a,t,e)

Here the preprocessor replaces the macro “begin” with the expansion decode(a,n,i,m,a,t,e). According to the macro definition in the previous line, the argument must be expanded so that the 4th, 1st, 3rd and the 2nd characters must be merged. In the argument (a,n,i,m,a,t,e) 4th, 1st, 3rd and the 2nd characters are ‘m’, ‘a’, ‘i’ and ‘n’.

So the third line “int begin” is replaced by “int main” by the preprocessor before the program is passed on to the compiler. That’s it.

The bottom line is that, there can never exist a C program without a main function. Here, we are just playing a gimmick that makes us believe that the program runs without the main, but there actually exists a hidden main function in the program. Here, we are using the proprocessor directive to intelligently replace the word “begin” by “main”. In simple words: int begin = int main.