I've seen C++ Zero-out a struct array? and other SO posts. Unfortunately I haven't found anything that can initialize a char array member of a struct.
I have this struct
struct SettingsData {
ModeType Mode = ModeType::Off;
char Zone[26];
double Temperature = 0.0;
OnOffState Heater = OnOffState::Off;
OnOffState Airconditioner = OnOffState::Off;
OnOffState Fan = OnOffState::Off;
bool ApplianceOn = false;
};
I'm looking for C++ way of doing this. I realize I should use a member initializer lists but I can't figure out how to initialize the char array. I get
array used as initializer
error.
I've even tried
char Zone[26] = {'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'};
No compile error, but I'm still seeing unwanted "data" in the Zone member.