Home / Questions / Can we compile a program without main() function?
Explanatory Question

Can we compile a program without main() function?

👁 1,182 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

Answer with Explanation

Yes, we can compile, but it can't be executed.

But, if we use #define, we can compile and run a C program without using the main() function. For example:


#include<stdio.h>    
#define start main    
void start() {    
   printf("Hello");    
}