0
010 010
I found this very odd and maybe someone can explain it to me.
I was using fread to scan through a binary file and pull bytes out. In
the middle of a while loop, for no reason that i could discern, fread
all the sudden kept returning the same byte over and over as if it were
no longer advancing in the file. I used a hex editor to determine the
address of the last byte read in the file. CF was the last address, D0
was not ever read although my while loop kept running.
when i tried to use ftell to try to debug the problem, the program ran
fine. mmm, so i took the ftell out and the program ceased working
again. the ftell wasn't doing anything that i could tell. this is my
loop:
while (blah2!=3220) // I'm still working out bugs and using
temporary variables like "blah"
{
fread(&newval,BPS,1,WavInPtr); //put new byte in
newval
blah=oldval^newval[0];
ftell(WavInPtr); // fread forgets about itself
without this
if(blah < 0)
{
oldval = newval[0];
fprintf(WavOutPtr,"%ld \n",period_cntr);
period_cntr=0;
}
++period_cntr;
++blah2;
}
as you can see, ftell isn't attached to anything, it isn't doing
anything that i can see. but if i take it out, the program just runs
fine to a certain point and then stops making sense.
I'm compiling on Dev-c++ 4.9.9.2
I'd be glad to send the source code to anyone who wants to play with it
themselves. it requires a small wav file that comes with it.
I was using fread to scan through a binary file and pull bytes out. In
the middle of a while loop, for no reason that i could discern, fread
all the sudden kept returning the same byte over and over as if it were
no longer advancing in the file. I used a hex editor to determine the
address of the last byte read in the file. CF was the last address, D0
was not ever read although my while loop kept running.
when i tried to use ftell to try to debug the problem, the program ran
fine. mmm, so i took the ftell out and the program ceased working
again. the ftell wasn't doing anything that i could tell. this is my
loop:
while (blah2!=3220) // I'm still working out bugs and using
temporary variables like "blah"
{
fread(&newval,BPS,1,WavInPtr); //put new byte in
newval
blah=oldval^newval[0];
ftell(WavInPtr); // fread forgets about itself
without this
if(blah < 0)
{
oldval = newval[0];
fprintf(WavOutPtr,"%ld \n",period_cntr);
period_cntr=0;
}
++period_cntr;
++blah2;
}
as you can see, ftell isn't attached to anything, it isn't doing
anything that i can see. but if i take it out, the program just runs
fine to a certain point and then stops making sense.
I'm compiling on Dev-c++ 4.9.9.2
I'd be glad to send the source code to anyone who wants to play with it
themselves. it requires a small wav file that comes with it.