fstream

How does one create a text file without replacing the last one every time the program is compiled? Say for example you made a text document for a person to store his/her ID and password which is done using the command prompt so that the program can read from that file and then granting access to the person when logging in. But every time the program is compiled it replaces that file and erases the login data (ID/password) within.

ofstream write;
write.open("Account.txt");

I know this ain't much but you can see the point I'm trying to make



Try:
write.open("Account.txt", fstream::ate);
Last edited on
Nope... creates a new file. I was thinking of something like the program can look for the text file and if so then it does not create a new one. Like an IF statement.
Last edited on
You need to use fstream::app. This will append to an existing file.
Thank you very much!
Topic archived. No new replies allowed.