0 out of 2 rated this helpful - Rate this topic

CFile::Write

Writes data from a buffer to the file associated with the CFile object.

virtual void Write( 
   const void* lpBuf, 
   UINT nCount  
);
lpBuf

A pointer to the user-supplied buffer that contains the data to be written to the file.

nCount

The number of bytes to be transferred from the buffer. For text-mode files, carriage return–linefeed pairs are counted as single characters.

Write throws an exception in response to several conditions, including the disk-full condition.

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();

In addition, see the examples for CFile::CFile and CFile::Open.

Header: afx.h

Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.