It seems that the argv[argc]
is always NULL
, so I think we can traverse the argument list without argc
. A single while
lo
Yes, argv[argc]
is guaranteed to be a null pointer. argc
is used for convenience.
Quoting the official explanation from C99 Rationale, note the words redundant check:
Rationale for International Standard — Programming Languages — C §5.1.2.2.1 Program startup
The specification of
argc
andargv
as arguments tomain
recognizes extensive prior practice.argv[argc]
is required to be a null pointer to provide a redundant check for the end of the list, also on the basis of common practice.