Question: Couldn't find any questions on StackOverflow that addresses this question.

I realize that char\* arrays don't have to be NULL terminated, but was wondering when you would want it to be?

For example, when debugging my code, I use a lot of printf() to see if my variable is correct at certain stage of the code.

I have an char\*\* values that holds 4 char\*, I made the last char\* NULL.
With NULL terminating, printfs from values[0] to values[3] give me this
*note: names is just another array that I print right after I finish printing the values array*

```
Testing values1[0]: %HOME/bin:%PATH
Testing values1[1]: /%HOME/include
Testing values1[2]: /%HOME/lib
Testing values1[3]: (null)
Testing names2[0]: PATH
Testing names2[1]: IDIR
Testing names2[2]: LIBDIR

```

I have an char\*\* with 3 char\*, all of which are valid char\*.
Without NULL terminating, printf from values[0] to values[3] gives me this (names doesn't show)

```
Testing values1[0]: %HOME/bin:%PATH
Testing values1[1]: /%HOME/include
Testing values1[2]: /%HOME/lib

```

I think when printf(...., values[3]) would be an undefined behavior, such as printing a garbage value, but as shown in the output above, everything including and after printf(...., values[3]) seems to not have been executed.

Answer: 
I got an answer from my TA, as a response to "when should char\*\* be null terminated?" which I find reasonable. It would be cool if there are other reasons to why you would do this.

"This is a good conceptual question, and you can think of it as analogous to why C strings are null-terminated.

Suppose you didn't want to explicitly store the length of an array (because it's extra data for you to manage and pass around, etc). How would you know where the array ends? The NULL at the end acts as a sentinel value so you can simply iterate over it until you reach the magic end-of-array value.

If you have a fixed array size or are storing it in some other way, the NULL end isn't necessary."
In C99 (& POSIX), the only array of `char*` which is *required* to be `NULL` terminated is the `argv` second argument to `main`. Hence your `main` function is (or should be) declared as

```
int main(int argc, char**argv);

```

and (at least on POSIX systems) it is required (and enforced by the runtime [crt0](https://en.wikipedia.org/wiki/Crt0)) and you should expect that:

* `argc` is positive
* `argv` is an array of `argc+1` pointers, each of them being a C string (so ending with a `\0` byte)
* its last element `argv[argc]` is required to be the `NULL` *pointer*
* two different pointers in `argv` (i.e. `argv[`*i*`]` and `argv[`*j*`]` with both *i* and *j* being non-negative and less than `argc+1`) are not [pointer aliases](https://en.wikipedia.org/wiki/Pointer_aliasing) (that is the same pointer value)

Of course, some libraries may also have functions whose argument might have similar requirements. That should be documented.