CFile::Read
Reads data into a buffer from the file associated with the CFile object.
virtual UINT Read(
void* lpBuf,
UINT nCount
);
Parameters
lpBuf
Pointer to the user-supplied buffer that is to receive the data read from the file.nCount
The maximum number of bytes to be read from the file. For text-mode files, carriage return–linefeed pairs are counted as single characters.
Return Value
The number of bytes transferred to the buffer. Note that for all CFile classes, the return value may be less than nCount if the end of file was reached.
Example
CFile cfile;
cfile.Open(_T("Write_File.dat"), CFile::modeCreate |
CFile::modeReadWrite);
char pbufWrite[100];
memset(pbufWrite, 'a', sizeof(pbufWrite));
cfile.Write(pbufWrite, 100);
cfile.Flush();
cfile.SeekToBegin();
char pbufRead[100];
cfile.Read(pbufRead, sizeof(pbufRead));
ASSERT(0 == memcmp(pbufWrite, pbufRead, sizeof(pbufWrite)));
For another example see CFile::Open.
Requirements
Header: afx.h