Writing a C program with out using Main function
How to write a C program without a main function?. Is it possible to do that. Yes there can be a C program without a main function. Here’s the code of the program without a 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 “);
}
Does the above program run without the main function? Yes, the above program runs perfectly fine even without a main function. But how, whats the logic behind it? How can we have a C program working without main?
Here we are using preprocessor directive #define with arguments to give an impression that the program runs without main. 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 two or more characters with it.
NOTE: A Preprocessor is program which processess the source code before compilation.
Look at the 2nd line of program -
#define decode(s,t,u,m,p,e,d) m##s##u##t
What is the preprocessor doing here. The macro decode(s,t,u,m,p,e,d) is being expanded as “msut” (The ## operator merges m,s,u & t into msut). The logic is when you pass (s,t,u,m,p,e,d) as argument it merges the 4th,1st,3rd & the 2nd characters(tokens)
Now look at the third line of the program -
#define begin decode(a,n,i,m,a,t,e)
Here the preprocessor replaces the macro “begin” with the expansion decode(a,n,i,m,a,t,e). According to the macro definition in the previous line the argument must be expanded so that the 4th,1st,3rd & the 2nd characters must be merged. In the argument (a,n,i,m,a,t,e) 4th,1st,3rd & the 2nd characters are ‘m’,’a’,’i’ & ‘n’.
So the third line “int begin” is replaced by “int main” by the preprocessor before the program is passed on for the compiler. That’s it…
The bottom line is there can never exist a C program without a main function. Here we are just playing a gimmick that makes us beleive the program runs without main function, but actually there exists a hidden main function in the program. Here we are using the proprocessor directive to intelligently replace the word begin” by “main”. In simple words int begin=int main.
21:40
|
Labels:
c hack
|
Subscribe to:
Post Comments (Atom)
Pages
Powered by Blogger.
About Me
Blog Archive
-
▼
2012
(37)
-
▼
May
(21)
- Format error "Windows cannot format this Drive..."...
- Complete List of Run Commands for Easy Access in W...
- How to Make IDM Full Version without Patching
- Increase torrent download speed using software
- To convert a FAT partition to NTFS, perform the fo...
- How to remove Recycle Bin Icon from Desktop
- To remove shortcut arrow from desktop icons in any...
- Changing windows logon screen wallpaper
- Extend your trial period of Windows
- How to increase download speeds of uTorrent
- Knowing the password behind **** in browser
- Creating a folder with CON as name
- IDM crack for full version
- How to open a site when it is blocked at your scho...
- Writing a C program with out using Main function
- Resetting windows password when it is lost
- Getting bluetooth option in sendto menu
- Installing windows from a pendrive
- Making a folder locker without any software
- Downloading torrent files using idm
- WINDOWS HACKING
-
▼
May
(21)
visitors
CAUTION
- 3g hack
- aircel
- apple
- AVG
- bluetooth
- c hack
- cheat engine
- chrome
- commands
- fat32 to ntfs
- folder locker
- Format
- full version
- guest account
- hack
- hiding drives
- idm
- increase torrent speed
- installing windows7
- intel
- ios
- iphone
- lock pc
- logon
- low seeds
- Mac os x
- netsetter unlocking
- password
- pc tune up
- pendrive
- pendrive boot
- proxy
- Registry
- remove recycle bin
- remove timeline
- run
- short cut arrow
- Task Manager
- torrents
- trial period
- tune up
- ultrasurf
- virtual box
- windows
- windows 7
0 comments:
Post a Comment