0

If this is possible then any help would be great

I have already tried this code,

float deposit (float balance)
{


     double amount; 
    system("cls");
    cout<<"Enter the amount you wish to deposit"<<endl; 
    cin>>amount; 


    ofstream newBalance;                        
    newBalance.open ("deposit.txt", fstream::app);
    newBalance<<amount; 
    newBalance.close();

    balance = balance + amount; 
    writeBalance(balance); 
    return balance;  
}
//This is a function to allow the user to increase their balance 
David
  • 2,987
  • 1
  • 29
  • 35
user3257023
  • 43
  • 1
  • 10
  • possible duplicate of [How to append text to a text file in C++?](http://stackoverflow.com/questions/2393345/how-to-append-text-to-a-text-file-in-c) and [How can I append to a text file?](http://stackoverflow.com/q/13200079) – Ken White Jan 31 '14 at 15:32

1 Answers1

0

You may want to put

fstream::out | fstream::app

instead of just fstream::app

You can look at:

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

To put in a new line just do:

newBalance<<amount<<"\n";
James Black
  • 41,583
  • 10
  • 86
  • 166