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??
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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:)))
EXAMPLE
ofstream outs;
outs.open("somefile", ios::app);
outs<<"AnyString"<<endl;
outs.close();
*------------
so ios::app is the append mode:)))
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_CREA
CFile file(flH);
note that this file will not be closed in the file destructor so
use:
_close((HFILE)file);
;