I have a bank account file that the program should be able to read. This function works using ifstream. But I want the program to read the 6th line of a text file (which has a value of "balance"), and then update it as necessary (delete and replace with a new value).
I used the for loop to find the traverse along the lines. But how do I update it when necessary? (withdrawals and deposits update the balance)
This is the code I have:
ifstream file;
string line;
file.open ("accounts.txt", ios::in);
for(int i = 0; i < 6; ++i)
{
getline(file, line);
}
What will happen next? Thank:)
source
share