How to get the sizeof array of structs
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.