How To write a C Program without the main Function?
Here we have a c program which looks like it has no main function.
Can we write a C Program without the main function? the answer is No.
The main function is the entry point of your program, or in simple words from the main function your program starts execution.
But we can use the C PreProcessor and write a c program which looks like it doesn't contain amain function.
Example C Program to mimic no main function
1 #include <stdio.h>
2 /* create a macro which expands to main */
3 #define anil main
4
5 //create the function with macro name
6 //this macro name will be substituted with macro expansion part
7 // during the pre processing stage
8 int anil()
9 {
10 printf("Hello World");
11 return 0;
12 }