+ 1

Can You Write a C Program Without a Main Function ?

Have you ever wondered how to write a C program without a main function? Can a C program execute without a main function? Is it possible to do that?

26th Dec 2017, 2:22 PM
prosper
prosper - avatar
3 Answers
+ 3
#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("hai"); return 0; } output: hai
26th Dec 2017, 2:50 PM
C Lover
+ 2
No. Main function is a must in C Program. But still you can do some tricks using define to avoid it 😉 #include <stdio.h> #define xyz main void xyz(){ ... } But still main is always somewhere. 👍😁
26th Dec 2017, 2:35 PM
Aashish Kumar Shaw
Aashish Kumar Shaw - avatar