Program that allows the user to create an account (username and password) and writes that to a file and recalls it so that they can login to do banking within the program. Once inside the further menus, call the file (passed though username) so that their specific amount appears, and i want to manipulate that value; as far as like deposit, withdraw or show current balance. I'm going to show my deposit function specifically, as its what I'm currently wrestling with and I don't want to put the entire program in fear for someone stealing it as this is a school project.
My question is, how do I take their balance from the file, change it into an integer so that I can manipulate it and then, change it back into a string and write it back to the file. Or am I barking up the wrong tree completely and doing this wrong. Please help.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
void deposit(string userid)
{
string tempuser, temppass, balance, balancetwo;
fstream filelogin;
int amount, balanceN;
filelogin.open ("login" , ios::in|ios::out );
cout << "How much do you wanna deposit? (the more the better we gamble with your money) " << endl;
cin >> amount;
while (filelogin >> tempuser >> temppass >> balance )
{
if (tempuser == userid)
{
cout << "Your new balance after the transfer is: " << balanceN << endl;
}
}