Hi is there anyway to write a c program without main function.If so,point it out plz!
No. C is totally based off of the assumption that you start the program in main(). Anyway, why would you want this? This would make inconsistencies for other programmers reading your code.
C defines the entry point in a hosted environment to be main
. In a "freestanding" environment, however, the entry point can have some other name. That's about the only latitude the language (at least officially) allows in that particular respect.
The following linker abuse
char main[] = { /* Machine code for your target implementation */ };
will work on some platforms.
Maybe this could work: http://www.gohacking.com/2008/03/c-program-without-main-function.html
An alternative is to write a C program and look at the Assembly output: http://users.aber.ac.uk/auj/voidmain.shtml
More information about what happens before main() is called can be found here (How Initialization Functions Are Handled): http://gcc.gnu.org/onlinedocs/gccint/Initialization.html