I think we do not understand each other so I will try to explain what is this all about.
If we forget about this part
string na; //number of accounts
accfile >> accs[1].accno;
getline (accfile, ucty);
atoi(na);
cout <<"Reading from first line = " << na << endl;
Program open ex.file accounts.dat
Compare how many accounts there in case that I want to add new account ( this function doesn't exist yet)
Than I'm telling it to do withdraw from account number ...
It is searching dat file till find match of accounts numbers
Print out account number and current balance
Close dat file which stays in buffer
Open file for writing
And update
This is working with no problems at all
But I wanted to state on the first line of dat file how many accounts are there
This not happening because of this little piece of code
string na; //number of accounts
accfile >> accs[1].accno;
getline (accfile, na);
atoi(na);
cout <<"Reading from first line = " << na << endl;
where at begginnig am trying to reade first data accno "account number" and forget about rest of line. This should tell me that there are 3 accounts. However this code find out there is word account does Withdraw and overwrite file it's own way. Why ???
P.T.
|