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

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -