C Program to Write C Program Without using Main Function in 3 ways

Run C Program Without Main Function
Conceptually C Program is meaningless without main Function . Every Program Must have Main Function.
Main Function :

  • It is Entry Point of Every C Program.
  • All Predefined and User-defined Functions are called directly or indirectly through the main.
  • So C Program Must have Main Function.

But I have decided not to write main and want to run C Program , How ?
We have 3 approaches of Writing C Program without using main().

Way 1 : Using #define Preprocessor Directive

What Preprocessor is doing Here ?

  1. Save C Program using Extension .C
  2. Before Program is given to compiler program is processed by Preprocessor .
  3. Source Program is scanned from Left to Right and from Top to Bottom and “begin” is replaced by “main”
  4. 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

Explain ?

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

Way 3 : Using Argumented Macro

Explain ?

  1. See Argumented Macro