Deleting account information from a file
Aug 4, 2013 at 9:54pm UTC
I'm attempting to delete an account from my accounts.txt file, but I can't seem to get it to work. I'm attempting to put white spaces into the account file, but it doesn't seem to be working.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
//function: delete account
void delAct(account one[]){
int actChoice;
ofstream fdata;
int x = 0;
cout << "Enter the account number you would like to delete: " ;
cin >> actChoice;
while (!(actChoice == one[x].actNum)){
x++;
}
if (actChoice == one[x].actNum){
cout << "You have selected...\n\n" ;
cout << "Account number: " << one[x].actNum;
cout << "\n" ;
cout << "Acount name: " << one[x].name;
cout << "\n" ;
cout << "Balance: " << one[x].balance;
cout << "\n" ;
}//if
fdata.open("accounts.txt" );
if (fdata.fail()){
cerr << "Error opening file" << endl;
system("PAUSE" );
exit(1);
}//if
fdata << " " ;
fdata << " " ;
fdata << " " ;
fdata.close();
}//void
Topic archived. No new replies allowed.