c++ - Initialisation of char array to string value, are the uninitialised indices set to null? -
if have following:
char test[10] = "#";
is test[1]
through test[9]
guaranteed \0
? or test[1]
guaranteed \0
?
this definition
char test[10] = "#";
is equivalent to
char test[10] = { '#', '\0' };
that 2 elements of array initialized explicitly initializers. other elements of array 0 initialized implicitly set tto '\0'
according c++ standard (section 8.5.2 character arrays)
3 if there fewer initializers there array elements, each element not explicitly initialized shall zero-initialized (8.5).
Comments
Post a Comment