Does fread move the file pointer?

richardaum picture richardaum · May 22, 2012 · Viewed 29.1k times · Source

Simple question,

When i use fread:

fread(ArrayA, sizeof(Reg), sizeBlock, fp);

My file pointer, fp is moved ahead?

Answer

David Heffernan picture David Heffernan · May 22, 2012

Yes, calling fread does indeed move the file pointer. The file pointer will be advanced by the number of bytes actually read. In case of an error in fread, the file position after calling fread is unspecified.