fread() not working on second loop

I'm having a huge problem. I have a loop, and within the loop I use fread() multiple times. However there is one call I make that only works on the first loop. Here is an example of how my loop works:


long remaining;
long othervalue;
FILE* myFile;

myFile = fopen("File.bin", "r");
for (int i=0; i<2; i++)
{
fread(&othervalue,1,sizeof(long),myFile); //This one works on all loops
fread(&remaining,1,sizeof(long),myFile); //This only works on the first loop. After that variable "remaining" doesn't change.
}
fclose(myFile);

I have verified that the seek position is correct and other factors that may contribute, so I think its a problem with my pointer.

Any suggestion on this?


Last edited on
I am not sure what exactly you mean when you "works". I don't know what File.bin contains but I just wrote some random text in it to test out the code. And your othervaluev is also not changing.
If you could tell what exactly is "working" then it would be little bit easy to compile. :)
Topic archived. No new replies allowed.