Every one knows that C program execution starts from main() function. But I ll like to show u one program that can run without main() function.
#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(” hello “);
}
Here we are using preprocessor directive #define with arguements to show that program runs without main() function. But in reality it runs with a hidden main function.
The '##' operator is called the token pasting or token merging operator. That is we can merge 2 or more characters with it.
Note : A preprocessor is program which processess the source code before compilation.
So the moral is that we can never run a program without main() function here we are playing just a trick.
#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(” hello “);
}
Here we are using preprocessor directive #define with arguements to show that program runs without main() function. But in reality it runs with a hidden main function.
The '##' operator is called the token pasting or token merging operator. That is we can merge 2 or more characters with it.
Note : A preprocessor is program which processess the source code before compilation.
So the moral is that we can never run a program without main() function here we are playing just a trick.
No comments:
Post a Comment