What do I think Main() does

So going by the name of the function Main(). I think that it is where you start from when you run the application. Ben said that you had to write the function before you use it, and it was before the Main function.

The way I think it (and I am a newbie so take with grain of salt)
The program goes through the code from top down
ie. it learns what functions and variables exist etc. but it doesn’t run those per se.

When it reaches the Main() it actually executes and the Main () can use things from above.

Function Main() is required by the compiler and must be in every C++ program. All statements, function calls, etc., are executed from within this function. When a call is made to an outside function, control will eventually be returned to function Main(), which will terminate with a return 0 to the operating system to indicate proper termination. I hope I’m right…

I think the Main() function is the primary execution mechanism that gets compiled. All code inside your program should be inside this function.

Privacy & Terms