Quote:
Originally Posted by
Tribe
And what about negative numbers? I've seen the return -1; quite often
For a return from
main(), the return code is equivalent to a call to
exit() with that return code. And from the standards, the description of
exit(status) is:
Quote:
The value of status may be 0, EXIT_SUCCESS, EXIT_FAILURE, or any other value, though only the least significant 8 bits (that is, status & 0377) shall be available to a waiting parent process.
For a return from any other function, the return value is determined by how that function is declared and the documented behavior of that function. For example, in C,
fopen() returns a FILE pointer or NULL;
sprintf() returns a pointer to a string or NULL,
strtoll() returns a signed long long integer,
strtoull() returns an unsigned long long integer, etc.