C++ I want to write to a text file but on the next line to whatever text is already in the .txt file -


if possible great

i have tried code,

float deposit (float balance) {        double amount;      system("cls");     cout<<"enter amount wish deposit"<<endl;      cin>>amount;        ofstream newbalance;                             newbalance.open ("deposit.txt", fstream::app);     newbalance<<amount;      newbalance.close();      balance = balance + amount;      writebalance(balance);      return balance;   } //this function allow user increase balance  

you may want put

fstream::out | fstream::app 

instead of fstream::app

you can at:

http://www.cplusplus.com/reference/fstream/fstream/open/

to put in new line do:

newbalance<<amount<<"\n"; 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -