There are two places you may be using
return 0
in C++:
1) At the end of your
main
function
2) At some point in another function.
When your main function exits, it returns a status code to the operating system, which - if your app runs under DOS or CMD - is checked to decide if your app functioned normally. A value of 0 indicates "all ok, normal exit", any other value is normally an error code which says
why your app exited at that point. U=You can return any value, but some values do have specific meanings:
DOS ERROR CODES[
^]
If you return zero in a "normal" function, it's probably a boolean value. Because C does not have a true or false value, it works with 0 / nonzero. 0 is "False", any other value is "True" - and because C++ grew from C it's still perfectly valid. So a return value of 0 is very often the equivelant of "return fasle", and any other value is "return true". That's why you often see code like:
char myString[] = ...
char *p = myString;
while (*p)
{
...
p++;
}
To traverse a null terminated string - it stops at the first null character '\0' because zero is "False".
[edit]:blush: wrong way round, Griff - go get caffeine [/edit]