c++builder-6

How to zero array members when my compiler isn't standard conform

旧时模样 提交于 2019-12-01 19:06:17
My compiler (C++Builder6) syntactically allows array member initialization (at least with zero), but actually it doesn't really do it. So the assert in the example given below fails depending from the context. #include <assert.h> struct TT { char b[8]; TT(): b() {} }; void testIt() { TT t; assert(t.b[7] == 0); } Changing the compiler isn't an option at the moment. My question is: what will be the best way to "repair" this flaw with respect to future portability and standard conformance? Edit: As it turns out, my first example was too short . It missed the point, that the fill level of the