I am not new to Arduinos and Programming in C.
I am creating an array of a struct, and have an array of booleans within that struct,
I cannot get the boolean array inside the struct to initialize.
This is so easy in Python!!!
typedef struct {
char * l_name;
byte x_m;
byte y_m;
boolean period[];
} myStruct;
myStruct structs[30];
void setup() {
structs[0] = {"My Name", 0, 0, {true, true, false, false}};
structs[0] = {"My Second Name", 0, 0, {true, false}};
//.......... and so on.......
}
void loop() {
// put your main code here, to run repeatedly:
}
I get this error when compiling:
No match for 'operator=' (operand types are 'myStruct' and '<brace-enclosed initializer list>')
If I comment out the boolean array and remove that from the declaration of structs[0] everything is fine.
I could have a separate array holding the boolean items, but thisis not so elegant.
Each item in the structs array has a diffent number of boolean items. anything from 2 to 20.
If I set the period array to say 10, then it works, but I have blank items if there are less than 10 items.
Any help much appreciated.
Many thanks to you both.
Overnight I realised I could save the array as a uiny8_t then do Bit operations to get the value.
However, defining the array as it is created suits me better.
Regards