I'm trying to write a program which has x number of loops. Now I know that after this program is done I'll need to write very similar programs but with y or z number of loops. Basically each loop iterates a different variable in order to find the "best values" for all the variables of a mathematical function.
What I'd like to be able to do is to do something like this:
case 1:
case 2:
case 3:
case 4:
Does anyone know if there's a way to do this in straight C? I'm using XCode btw. The rest of my program is getting fairly hairy and I'd rather not have to split up my program into different versions for different numbers of variables because that would lead to debugging hell!! Any help would be greatly appreciated!!
What I'd like to be able to do is to do something like this:
case 1:
Code:
variables = 1
start loop_1
call function(variable 1)
end loop_1
case 2:
Code:
variables = 2
start loop_1
start loop_2
call function(variable 1, variable 2)
end loop_2
end loop_1
case 3:
Code:
variables = 3
start loop_1
start loop_2
start loop_3
call function(variable 1, variable 2, variable 3)
end loop_3
end loop_2
end loop_1
case 4:
Code:
variables = n
start loop_1
start loop_2
start loop_3
...
start loop_n
call function(variable 1, variable 2, variable 3, ..., variable n)
end loop_n
end loop_3
end loop_2
end loop_1
Does anyone know if there's a way to do this in straight C? I'm using XCode btw. The rest of my program is getting fairly hairy and I'd rather not have to split up my program into different versions for different numbers of variables because that would lead to debugging hell!! Any help would be greatly appreciated!!