Path: utzoo!mnetor!uunet!husc6!hao!oddjob!gargoyle!ihnp4!homxb!whuts!picuxa!gp From: gp@picuxa.UUCP (Greg Pasquariello X1190) Newsgroups: comp.lang.c Subject: Re: exit(main(argc,argv,env)); Message-ID: <421@picuxa.UUCP> Date: 18 Dec 87 13:11:32 GMT References: <10875@brl-adm.ARPA> <1451@houdi.UUCP> Organization: AT&T Information Systems, Parsippany NJ Lines: 12 Summary: main() not always the first called In article <1451@houdi.UUCP>, marty1@houdi.UUCP (M.BRILLIANT) writes: > > The key question is where the exit(main(..)) was found. Since main() > is the first function called, no statement is needed to invoke main(). > Put it another way, since main() is invoked anyway, any statement that > calls main() must call it recursively. Why would anybody do that? On the compilers that I have seen, main() isn't the first routine called. Rather, some startup code is included (typically called _main()) that in turn invokes main(). Therefor exit(main(argc,argv,envp)) is an efficient way (it saves a variable) to call main and return an exit status.