Each program has a main()
and the program execution starts from there. Is it possible to write a program without main()
and make another function as the entry point? If so, can any one please tell me how can that be done? I am using Linux?
What Is an Entry-Point Function? An entry point is a location in code where a transfer of program control (execution) occurs. The main function ( main() ) is the entry point to a C/C++ program and is called when the application starts executing.
it's not possible in c to have more than 1 main-function. you could use preprocessor directives like "#ifdef" to compile just one main-function at the time.
In computer programming, an entry point is the place in a program where the execution of a program begins, and where the program has access to command line arguments.
If you are on a system that provides GNU Binutils (like Linux), you can use the objcopy command to make an arbitrary function the new entry point. Save this answer.
If you're compiling with gcc, specifying -e <symbol>
option will let you change the entry point to a function symbol()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With