Re: Re: getopt and Solaris 10

[email protected] (Larry Jones) Tue, 10 May 2005 11:21:43 -0400 (EDT)
Newsgroups gmane.comp.lib.gnulib.bugs,gmane.comp.version-control.cvs.bugs,gmane.comp.gnu.core-utils.bugs
Message-ID <[email protected]>
Derek Price writes:
> 
> Okay, looking at that in C89 now, but just out of curiosity, if argv
> needs to be NULL terminated, what's the point of argc?

I believe it was added for convenience back in the dark ages.  All the
Unix exec functions require a null-terminated argument list (and don't
have an explicit argument count), so argv has naturally always been null
terminated.  (And the C Standard codified that behavior: at program
startup, argv[argc] is required to be null.)

-Larry Jones

I don't think that question was very hypothetical at all. -- Calvin