This was a feature of C from the start and ported to C ++.
In the case of string arrays, the solution was to add a trailing null character to mark the end.
This was probably done for the sake of efficiency when C started on ancient PDP computers.
Use strlen; or better yet std :: string or std :: vector.
source share