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: