String termination C/C++ char = 0

We are only assigning element at index ‘3’ to 0, but why do all
characters after that index are ignored? Can someone please explain
this behavior?

The convention with a zero-terminated string is that the 0 byte is what indicates the end of the string. So when printf() encounters the zero-byte at position 3, it stops printing.

Leave a Comment