From the C11 standard draft N1570, §5.1.2.2.1/2:
The parameters
argc
andargv
and the strings pointed to by theargv
array shall be modifiable by the program, and retain their last-stored
values between program startup and program termination.
They are modifiable. That means they are not string literals.
But be careful: the upper citation only refers to pointers to strings, excluding the obligatory null pointer at argv[argc]
1.
From the C11 standard draft N1570, §5.1.2.2.1/2 (same as above)1:
argv[argc]
shall be a null pointer
Notes:
-
Something regarding this sentence:
I know that you shouldn’t modify string literals as it can cause
undefined behavior […]“can”? It does always. Undefined behavior includes expected, as if well-defined, and unexpected behavior.
1 Thanks to @black!