There is no way that you can have a c program without main . Without the main your compiler will not know where to begin the execution of the program. So main is a must bust can fool your friends with this trick.
#include
#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(" hello ");
}
We are making use of preprocessor directive #define. A Preprocessor is program which processess the source code before compilation.
In the # define decode(s,t,u,m,p,e,d) you are asking the compiler to merge the 4th,1st,3rd & the 2nd characters(tokens). with the help of ##. So what you get "msut"
Similarly when you do decode(a,n,i,m,a,t,e) you get main. Now you are equating it to begin. So whereever the compiler find begin it will replace it with main. Using this principle/trick you can change anything.
Thursday, March 11, 2010
C/c++ program without main
12:14 PM
No comments
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment