L
Larry__Weiss
Richard said:The standard gives explicit permission to modify argv itself and
the strings pointed to by argv[0] through argv[argc - 1], but it doesn't
give permission to modify argv[0] through argv[argc - 1] themselves.
Strange that you can modify the strings, considering that they may
in fact be null strings. How can you modify a null string?
I would have found it more reasonable that you would have to leave the
original strings alone, but have the freedom to allocate and substitute
different strings in the argv array, or in fact allocate a new argv structure
and change argv to point to the new one.
On rereading the Standard (from 5.1.2.2.1 Program startup)
The parameters argc and argv and the strings pointed to by the argv
array shall be modifiable by the program, and retain their last-stored
values between program startup and program termination.
I can imagine that that means my alternative interpretation without too much stretch.
It might mean not that the content of the original strings are modifiable, but
that the strings themselves can be substituted for other strings.
Where are the examples? The Standard should be overflowing with examples
of code that reinforce what the prose text says.
- Larry Weiss