Are char * argv[] arguments in main null terminated?

Yes. The non-null pointers in the argv array point to C strings, which are by definition null terminated.

The C Language Standard simply states that the array members “shall contain pointers to strings” (C99 § A string is “a contiguous sequence of characters terminated by and including the first null character” (C99 §7.1.1/1), that is, they are null terminated by definition.

Further, the array element at argv[argc] is a null pointer, so the array itself is also, in a sense, “null terminated.”

Leave a Comment