Subject: Re: Answer to "which echo.c"
To: Todd Vierling <tv@pobox.com>
From: David Maxwell <david@fundy.ca>
List: current-users
Date: 12/09/1999 16:36:45
On Thu, Dec 09, 1999 at 02:37:54PM -0500, Todd Vierling wrote:
> : It uses return(0), when exit(0) would be the proper thing.
> Not necessarily (and I'm not trying to endorse, believe me)....
> Unless you're talking about style here, see crt0 for any *BSD architecture
> and make note of what gets called with the return value of main().  (Hint:  
> it also has an "e" and an "x" in "it".  ;)

Definitely style. Here's a gross example:

main(argc,argv)
int argc;
char *argv[];
{
if (argc)
        {
        puts(argv[0]);
        main(--argc, ++argv);
        }
        else
        {
        return(0);
        }
return(0);
}

This program is small enough to be taken in at a glance, if it weren't
however, one of those returns being an 'exit' would make it much clearer.

-- 
David Maxwell, david@vex.net|david@maxwell.net --> Mastery of UNIX, like
mastery of language, offers real freedom. The price of freedom is always dear,
but there's no substitute. Personally, I'd rather pay for my freedom than live
in a bitmapped, pop-up-happy dungeon like NT. - Thomas Scoville