Strange return codes from old but good C program
freebsd at edvax.de
Sun May 17 16:56:41 UTC 2015
On Mon, 18 May 2015 02:43:06 +1000 (EST), Ian Smith wrote:
> Instead of fixing the declaration and adding return 0, would exit(N) do?
That would be possible, see "man 3 exit" for details.
To signal a normal program termination, use exit(0);
and for errors, exit(1);
When return 0; is encountered within main(), it will
generate exit code via exit() and _exit() in the same
way as if you'd just call exit(). The main() function
is nothing special - every non-void function returns
You could explicitely add the (int) return type for
the main() function; typical forms are:
int main(void) ---> doesn't access command line parameters
int main(int argc, char *argv) ---> accesses them
This is (almost) equivalent to the K&R form:
which you probably have there somewhere.
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
More information about the freebsd-questions