Wednesday 4 September 2013

C program without main function...

Code:
#include<stdio.h>
#define decode(s,t,u,m,p,e,d)m##s##u##t
#define mepco decode(a,n,i,m,a,t,e)
int mepco()
{
    printf("hello");
}


Surprisingly,this code works succesfully....:D

Letz see how the hell does this code work....:)

Firstly,## is known as token merging operator.
and #define is a macro which replaces a word with another word that is specified....

So,in our code....
decode (s,t,u,m,p,e,d)m##s##u##t..........4,1,3,2 characters of the given string
similarly mepco decode (a,n,i,m,a,t,e) => m,a,i,n

Thus, int mepco() finally becomes int main() during the pre-processing stage itself and hence the code works....:) 

LOL!!

Join me on Facebook