How to get the sizeof array of structs I'm trying to make a use of a relay module,
I want a clear way to configure and control my relay module
I've defined the struct and filled it with some info about id, pin number, title, and relay state
I can't loop with for in the array of controls, because I can't get the sizeof the array right
typedef struct{
  int id;
  int pin;
  String title;
  bool state;
}  SwitchControl;

SwitchControl controls[2] = {
  {1, 22, &quot;Switch 01&quot;, 1},
  {2, 23, &quot;Switch 02&quot;, 0},
};


for(int i=0; i&lt;sizeof(controls) - 1; i++){
}

thanks
To make it generic, you simply divide the sizeof the array by the sizeof the type:
for(int i=0; i&lt;sizeof(controls)/sizeof(SwitchControl); i++){
}

Then you can later change the items if the array, or the structure and the code will be the same.