Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 May 2015 18:56:30 +0200
From:      Polytropon <>
To:        Ian Smith <>
Subject:   Re: Strange return codes from old but good C program
Message-ID:  <>
In-Reply-To: <>
References:  <> <> <>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
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
something. :-)

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:

main(argc, argv)
int argc;
char **argv;

which you probably have there somewhere.

Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...

Want to link to this message? Use this URL: <>