Originally Posted by
rambo5330
in this particular situation it will start to read in numbers and then print them out but eventually they dissapear and all that is left on the screen is zero... when i change the last for loop to x<= 20 or so.. it will print a few numbers and keep them on the screen... any idea what is going on here or if im even trying to read this wave file properly?
Your problem is in this section
Code:
for (k=0; k<=5001; k++)
{
if ((fread(&clip_info[k],2,5000,file_in))!= NULL)
{
fread(&clip_info[k],2,5000,file_in);
}
}
That condition is actually reading twice for each iteration. And you are telling fread() to read 5000 items of 2 bytes each into clip_info[k].
Code:
for (k=0; k < 5000; k++)
{
if ((fread(&clip_info[k],2,1,file_in))!= 0)
{
// fread(&clip_info[k],2,5000,file_in);
}
Note: the section that is out commented. This is just a quick edit you need to solve the error checking of fread in a different way.