Path: utzoo!mnetor!uunet!husc6!cmcl2!rutgers!ucla-cs!alex From: alex@CS.UCLA.EDU Newsgroups: comp.lang.c Subject: Re: return vs exit() Message-ID: <10033@shemp.UCLA.EDU> Date: 22 Dec 87 17:17:04 GMT References: <10875@brl-adm.ARPA> <176@fxgrp.UUCP> <1286@laidbak.UUCP> <1293@laidbak.UUCP> Sender: root@CS.UCLA.EDU Reply-To: alex@CS.UCLA.EDU (Alex Quilici) Organization: UCLA Artificial Intelligence Laboratory Lines: 15 In article <1293@laidbak.UUCP> daveb@laidbak.UUCP (Dave Burton) writes: >OK. [return and exit()] are equivalent. >K&R says so, K&P says so, H&S says so, etc., etc. > >Have return and exit() always been equivalent? > >If so, why is there an exit() function call, since > the semantics are the same? A *return from main* and exit() are equivalent. But you can use exit() to leave your program from any function within it. If nothing else, exit() is convenient for fatal-error handlers. Alex