I ran into a cast type problem which i do not quite know how to
approach, please help.
I have a float variable s initialized to 0. in a loop i use following
code:
s=s+(float)score[tmp1];
score is a char array. this array contains numbers 1-5.
it seems that every time loop executes s is increased by about 50,
increases range from 48 to 53 ish.
without the cast i get exactly same behavior.
I can verify that values in s are ranging from 1 to 5 with print
statement using %c in the print.
Full loop is below, score is a global variable.
================start paste==================
while(i1<ML[movie][1]){
weight=weight+1;
tmp1=i1+ML[movie][0];
s=s+(float)score[tmp1];
printf("score in loop is: %c",score[tmp1]);
printf("s is: %f\n",s);
i2++;
i1++;
}
================end paste=================
sorry cant post full code, its rather long and to run requires a
rather large pre-formatted dataset in same dir.
Thanks ahead for ur help.