Why is int main() so much better than void main() when in theory you never go oustide of main to get the return value (or do you??)?
Why is int main() so much better than void main() when in theory you never go oustide of main to get the return value (or do you??)?
The return value goes to the operating system
So if you add error checking to your program, say if a file cant be opened then return -1, if a file cant be created return -2.
This can be useful in debugging. When running MSVC++ in the output window at the bottom the return value of your program is shown after it is done running.
This more or less explains the difference between the two: http://www.cprogramming.com/boardfaq.html#main
I myself always use int main(void) as per the C standard.
alpha561
"You don't want to sell me death sticks"