Why is main an "int" and not a "void"?

Just curious, why is main an “int” and not a “void”? Void would seem like the most simple thing you could use. Couldn’t we even use a string?

Because when main finishes running, it sends an int to the system. Which int it returns tells the system the outcome of running main, ie if it crashed, there was an error, or it ran successfully.

Ok, Thanks!

Privacy & Terms