Can You Write a C program without main() ?


Trouble No. 011

C programming language, is Mother of all New languages we study.

Most of the people know that C program must have main() function to execute.

But, Have you imagine we can run C program without main() function too..!

Looking somewhat interesting right, Let’s see,

There are 2 ways to execute C program.

Way 1:

Using #define Preprocessor Directive


#define begin main


int begin() {


   return (0);



  1. Save C Program using Extension .C
  2. Before Program is given to compiler program is processed by Preprocessor .
  3. begin main
  4. Source Program is scanned from Left to Right and from Top to Bottom and “begin” is replaced by “main”
  5. So Programmer feels that “He has written Code Without using Main , but internally begin is already converted into main”


Way 2:

Using #define Token Merging Operator


#define begin m##a##i##n


void begin() {




  1. The ‘##‘ operator is called the token pasting or token merging operator.
  2. That is we can merge two or more characters with it.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s