Path: utzoo!attcan!uunet!mcsun!unido!mikros!mwtech!martin From: martin@mwtech.UUCP (Martin Weitzel) Newsgroups: comp.lang.c Subject: return in main is *not* equivalent to exit() (was Re: main() arguments) Message-ID: <833@mwtech.UUCP> Date: 4 Jul 90 14:33:15 GMT References: <78627@srcsip.UUCP> <78633@srcsip.UUCP> <25247@mimsy.umd.edu> <4238@jato.Jpl.Nasa.Gov> Reply-To: martin@mwtech.UUCP (Martin Weitzel) Organization: MIKROS Systemware, Darmstadt/W-Germany Lines: 29 In article <4238@jato.Jpl.Nasa.Gov> kaleb@mars.UUCP (Kaleb Keithley) writes: > >Furthermore, on p. 164 (Ibid.) [K&R2] it is stated: > >Within main, return expr is equivalent to exit(expr). exit has the >advantage... K&R2 is right? Nearly right! I'll never forget the day when I tracked down what seemed to be a really wierd problem in some printer driving code to the following (still buggy!) program: #include int main(argc, argv) int argc; char **argv; /* OK so, Chris? :-) */ { char buffer[BUFSIZ]; setbuf(stdout, buffer); ........ /* some code which produced output */ return 0; } Note that the bug could be eliminated by replacing `return 0;' with `exit (0);'. Well, after that the cause for this problem became obvious to me ... of course, all of you readers out there in net-world allready know what the problem is, don't you :-) -- Martin Weitzel, email: martin@mwtech.UUCP, voice: 49-(0)6151-6 56 83