Testing EOF with WriteFile/ReadFile ...
My aim is to read/write multiple records to a file. I've only worked with fprintf/fwrite & fscanf/fread... My first attempt in using Win32 API WriteFile is...
Q. Does ReadFile() return NULL when it has reached the end of file, or when the file is empty, or does not exist? I wanted to add an if statement to test for a FALSE return then print an error message, but what if FALSE means the file has finished reading...
// Retrieve saved records of radar from file an opened file
void ReadFromFile(CALC_DATA data, DWORD fileSize)
// Open for reading
HANDLE inFile = fileOpen("RFSfile.dat", OPEN_EXISTING, GENERIC_READ);
// Loop through records of file & read
while( ReadFile(inFile, data, sizeof(data), &fileSize, NULL) && fileSize > 0 );
// Create file for in/out
void fileOpen(LPCTSTR lpFileName, DWORD fileDiscript, DWORD acces)
// Create file for either writing or reading
if ( CreateFile(lpFileName, acces, 0, 0,
fileDiscript, 0, 0) == INVALID_HANDLE_VALUE )
WriteFile(STD_ERROR_HANDLE, "Error opening source: %d", GetLastError());
is there a Win32 feof()( like function?