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
Post a Comment