[LCP]Why do I do this? or exit() vs. return

Buddy Lumpkin b.lumpkin at comcast.net
Wed Jul 16 07:24:01 UTC 2003


I always saw return and exit as having two completely separate purposes.
Consider having a menu function that calls another menu function, etc,
etc... If you want a master exit function that completely exits the
program you could just call exit rather than return, then return, etc...
or use something nasty like goto.

--Buddy

-----Original Message-----
From: linuxcprogramming-admin at lists.linux.org.au
[mailto:linuxcprogramming-admin at lists.linux.org.au] On Behalf Of Vincent
Penquerc'h
Sent: Thursday, July 10, 2003 2:19 AM
To: 'linuxcprogramming at lists.linux.org.au'
Subject: RE: [LCP]Why do I do this? or exit() vs. return

> I would stick to using exit because at some
> latter point the programmers may start using
> atexit and on_exit, and if this happens you 
> won't have to modify the code.

Falling off main or returning from it will call
any atexit registered routines.

> Beware of the differences between exit and
> _exit aswell.

But not when calling _exit (or abort, or when slapped
with a fatal signal, etc).

-- 
Vincent Penquerc'h 
_______________________________________________
This is the Linux C Programming List
:  http://lists.linux.org.au/listinfo/linuxcprogramming List




More information about the linuxCprogramming mailing list