Link to home
Start Free TrialLog in
Avatar of mejaz01
mejaz01

asked on

Append mode?

This might sound like an easy question but anyway:) How do we open a file in append mode in MFC??
Avatar of migel
migel

Hi!
you can use _open file with  _O_APPEND flag
and then use CFile constructor with getted file handle
i.e.
int flH = _open( "OPEN.OUT", _O_WRONLY | O_APPEND|_O_BINARY|_O_CREAT, _S_IREAD | _S_IWRITE );

CFile file(flH);
note that this file will not be closed in the file destructor so
use:
 _close((HFILE)file);
;
ASKER CERTIFIED SOLUTION
Avatar of TravisHall
TravisHall

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mejaz01

ASKER

I found out a better way to do that. So I just think it's nice to let you know as well

EXAMPLE

     ofstream outs;
     outs.open("somefile", ios::app);
     outs<<"AnyString"<<endl;
     outs.close();
*------------
so ios::app is the append mode:)))