string array with garbage character at end

You have to end the string with a \0 character. That’s why they are called zero terminated strings.

It is also wise to allocate 1 extra char to hold the \0.

Leave a Comment