Have you ever wondered how to write a C program without a main function? Can a C program execute with a main function? Is it possible to do that?
Well, the answer is YES! There can be a C program without a main function. Here is the source code of the program without a main function:
#include<stdio.h>
#define decode(s,t,u,m,p,e,d) m##s##u##t
#define begin decode(a,n,i,m,a,t,e)
int begin()
{
printf(” hello “);
}
The ‘##‘ operator is called the token pasting or token merging operator. That is, we can merge two or more characters with it. Now, look at the 2nd line of program:
What is the preprocessor doing here? The macro 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).
![](https://mrhacker.co/wp-content/uploads/2019/08/logo-7.png)