Selection statements are changing the values of my variables!!
Hi everyone,
Something mysterious is going on with my program and I'm just wondering if any of you had any idea what is happening.
I have a loop like so:
Code:
for(i=0;i<=apples;i=i+10){
pears=sqrt(pow((i-oranges[myfunction(i,oranges,apples)]),2));
printf("%f ",pears);
/*if(pears>30.0){
selection=5.0;
}
if(pears<=30.0){
selection=10.0;
}*/
}
When this is executed, I correctly get the pears values that are expected (a list of 100 numbers that run from 0 to 250 to 0 to 250 to 0 again).
However, when I uncomment the selection statements in order to actually do something useful with this list of numbers, the pears values all change! From a careful inspection, it seems the correct pears values are having the value of the 'selection' variable taken away from them. How are a couple of selection statements changing the value of a variable!?
Is it a programming fault or a compiler problem? I am using the DigitalMars C Compiler if that is of any use.
Thanks in advance,
T