I have this at file scope:
static char foo[256];
Is the memory initialised to zero on all platforms and build configurations? (i.e. is it standard C++).
In this program, the char array 'buffer' is that place. It is used to hold a sequence of digits until a space is encountered, at which point that sequence of digits is turned into an actual number, and the space is re-used for the next sequence of digits.
You can initialize a one-dimensional character array by specifying: A brace-enclosed comma-separated list of constants, each of which can be contained in a character. A string constant (braces surrounding the constant are optional)
In C++, when you initialize character arrays, a trailing '\0' (zero of type char) is appended to the string initializer. You cannot initialize a character array with more initializers than there are array elements. In ISO C, space for the trailing '\0' can be omitted in this type of information.
Is the memory initialised to zero on all platforms and build configurations?
Yes, all non-local variables are zero-initialised.
(i.e. is it C++ standard)
Yes. C++11 3.6.2 specifies how non-local variables are initialised. In particular:
- Variables with static storage duration or thread storage duration shall be zero-initialized before any other initialization takes place.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With