I have a structure with similarly named variables such as
char c1;
char c2;
char c3;
char c4;
char c5;
char c6;
char c7;
char c8;
What I need is a loop that compares an input with each.
//Something Like
for(int i = 1; i <= 8; i++) {
if(compared == foo->c(i)) {
return compared;
}
}
Right now I have a long list of if and elses. I cannot change the struct unfortunately. If the long string of if/elses are the most effective way of doing it (performance not how good the code looks) then Ill just keep it like that.
I basically want a loop that changes the variable name that I am currently comparing to make the code less messy and hopefully faster.