float deposit( int x, int currentBalance)
{
cout<<"\n"<<endl;
cout<<"Welcome to the deposit area"<<endl;
cout << "Your new balance is:" << balance <<endl;
cout<<"Enter a sum you wish to add to your account:";
cin>> x ;
balance = x + currentBalance;
cout << "Your new balance is:" << balance <<endl;
fstream myfile;
myfile.open ("balance.txt");
myfile << balance;
myfile.close();
cout<<"\n"<<endl;
cout<<"Press 0 for further action or press 9 to exit." <<endl;
cin >> option;
if (option == 9)
{
exit(0);
What do you mean? Replace the value where? In the file, when you write the new balance to the file? Or in memory when running the program.
If you want help, you're going to have to be clear and detailed about what it is you're looking for. We're not interested in playing Twenty Questions with you.
Sir, the code i got there is store the value to text file called (balance.txt) and it sums up, every time i add more deposit.
but when i close the program the balance goes back to 0. I want to store the balance permanent , so every time i run the balance is there and i can add another deposit.
English is not first language, find quite difficult to explain what i want.
OK. But we're not going to write your program for you. You'll need to have a go at writing it yourself. Then, if you have a specific problem that you can't solve, we can help solve it.