How big is the argv[] array?
Doug Gwyn
gwyn at smoke.ARPA
Wed Oct 5 15:01:56 AEST 1988
In article <1239500004 at osiris.cso.uiuc.edu> hood at osiris.cso.uiuc.edu writes:
>How big is the argv[] array? Or to ask it another way, how safe is it to
>go past the argc-1'th element in the argv[] array?
What puzzles me is the line of reasoning you would use to conclude
that accessing nonexistent data could ever be safe.
argv[argc] is supposed to be a null pointer, and as you note you
can test for that instead of using a counter. (However, getopt()
works best with the counter approach.) Some older systems did
not have a null pointer in argv[argc], however. I don't think
you're likely to encounter any such systems today.
argv[argc+1] is simply undefined. Any use of it would be at your
own risk; in other words: don't do it.
More information about the Comp.lang.c
mailing list