#include <fstream>

Write your question here.
Is it possible to store into a text file without overwriting the existing information?

ofstream outf;

int x;

int main ()
{
outf.open (''.......'');
cout <<''Enter Desire Digit''<<endl;
cin >>x;

outf <<x<<endl;
return 0;
}
Use the append parameter.

 
std::ofstream outFile( "filename.txt", ios::app );


http://www.cplusplus.com/doc/tutorial/files/
Yes. Pass the ate (or app) flag when opening the stream.
http://en.cppreference.com/w/cpp/io/basic_ofstream/basic_ofstream#Parameters

 
outf.open (".......", ios::ate);
Last edited on
Thanks guys, the 'app' worked but 'ate' didnt
Topic archived. No new replies allowed.