I am programming Arduino and I have trouble when using the following code
struct myStruct {
char variable1[10];
char variable2[10];
char variable3[10];
// Constructor
myStruct() : variable1({'\0'}), variable2({'\0'}), variable3({'\0'}) {}
};
since I get the following error:
expected primary-expression before '{' token
What is the problem? How can I solve it?
Note: The \0
is used for handling null terminated strings.
BTW: Why the following code works and the above does not?
struct myStruct {
char variable1[10];
char variable2[10];
char variable3[10];
} variable = {{'\0'}, {'\0'}, {'\0'}};;