R
Rox
Hi group,
For array initialization, I found this in [n1539] 6.7.9
14.
An array of character type may be initialized by a character string literal
or UTF−8 string
literal, optionally enclosed in braces. Successive bytes of the string
literal (including the
terminating null character if there is room or if the array is of unknown
size) initialize the
elements of the array.
19 ...
all subobjects that are not initialized explicitly shall be initialized
implicitly the same as
objects that have static storage duration.
and
So I presume:
char c[10] = "";
Will initialize c into 0. Just like memset do.
It's such a neat way to initial a string that I can't believe it!
Am I right?
PS: I verified this on several gcc versions, both gcc and g++, and it just
WORK
Rox
For array initialization, I found this in [n1539] 6.7.9
14.
An array of character type may be initialized by a character string literal
or UTF−8 string
literal, optionally enclosed in braces. Successive bytes of the string
literal (including the
terminating null character if there is room or if the array is of unknown
size) initialize the
elements of the array.
19 ...
all subobjects that are not initialized explicitly shall be initialized
implicitly the same as
objects that have static storage duration.
and
So I presume:
char c[10] = "";
Will initialize c into 0. Just like memset do.
It's such a neat way to initial a string that I can't believe it!
Am I right?
PS: I verified this on several gcc versions, both gcc and g++, and it just
WORK
Rox