I am using the VC++ function
ReadFile(FileHandle,charBuf,noOfBytesToRead,&noOfBytesRead,NULL);
inside a for loop; in each iteration of the foor loop the FileHandle moves forward in the file i.e in each iteration we are reading a particular unit of the file and copying that unit (bunch of data in file) of data in file to char * array.
This amount of data to be read (from the file to char * array) in each iteration is determined by "noOfBytesToRead".
For some no: of iterations the ReadFile() is working fine but I observe that for some "n"th iteration (while reading nTH bunch of data) the 4th argument (noOfBytesRead) in the above call is set to 0 even though ReadFile() returns 1.
Return value of ReadFile() is 1 indicating success & the 4th parameter "noOfBytesRead" is set to 0, instead of no: of bytes Read. This is contradictory! Why is this so?
Can anyone kindly help me in this. ReadFile() being an Win API I can't even step into code to debug further.
From MSDN:
If the return value is nonzero and the number of bytes read is zero, the file pointer was beyond the current end of the file at the time of the read operation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With