argv[] terminated by a NULL pointer?
Daniel Jimenez
djimenez at ringer.cs.utsa.edu
Fri Jun 28 15:23:39 AEST 1991
In article <14603 at dog.ee.lbl.gov> torek at elf.ee.lbl.gov (Chris Torek) writes:
>In article <12187 at hub.ucsb.edu> angst at cs.ucsb.edu
>(Hopelessly in love w/Donna Reed) writes:
>>I'm porting some code that assumes that the argv[] array is terminated
>>by a NULL pointer.... am I right in my belief that argv[] is not
>>*guaranteed* to be terminated by a NULL pointer?
>
>Under Version 6 Unix, argv[argc] is (char *)-1. This violates the
>following wording from X3.159-1989 (`ANSI C'):
>
> argv[argc] shall be a null pointer. (2.1.1.2, p. 7)
>
Who said the null pointer couldn't be -1?
On a system where the null pointer is represented by all bits one,
the following statement:
((char *)0) == ((char *)-1)
would be true, since 0 in a pointer context is defined to be
the null pointer, and -1 is also the null pointer.
They would have the same bit pattern.
--
* Daniel A. Jimenez * Please excuse my longwindedness.
* djimenez at ringer.cs.utsa.edu * This Sun terminal makes everything
* dajim at lonestar.utsa.edu * I write seem important.
* Opinions expressed here are mine only, and not those of UTSA.
More information about the Comp.lang.c
mailing list