Hello, I'm confused about what exactly returning an integer is for and what it can do if it is not a zero, I understand that when a program reaches "return 0;" it ends the program but what is the zero returning to? And what would happen if you were to type "return 3;" or something like that? What is the purpose of returning an integer?
It returns the value to the operating system. In most cases it's ignored. But if your running your application from within another application, or within a script then you can check to see if something went wrong.
The value returned by main() is passed to the operating system. Returning a value makes more sense when writing command line programs. For example, suppose you wrote a copy program that returns the number of errors there were (0 being, of course, no error). This value can be evaluated in a shell script to change the behavior of the script based on the result of the program.
If the program is expected to not communicate with the operating system this way, then just return 0 always.
Some compilers let you return nothing, but that's not standard, and thus it won't compile everywhere.
thank you very much, now it's making a bit more sense, I'm actually trying to teach myself C++ and it's my first language too. (Aside from a bit of HTML). I think I'm getting the hang of some stuff but there are quite a few barriers yet to be crossed before I start to take off, but that certainly helps, and again thank you guys for the response!!