Quote
opens 2 file for reading and writing,
asks an account number,
then search the account number from clients.txt file
then copy the whole record inside clients.txt going to clients1.txt except for the account number that has been entered
delete clients.txt
rename clients1.txt to clients.txt
asks an account number,
then search the account number from clients.txt file
then copy the whole record inside clients.txt going to clients1.txt except for the account number that has been entered
delete clients.txt
rename clients1.txt to clients.txt
this work great though, but I want to add a message if the input account number is not found on the file
here's my code
ofstream outClientFile("clients1.txt", ios::out);
ifstream inClientFile("clients.txt", ios::in );
cout<<"Enter the Account Number you want to delete."<<endl;
cin>>number;
{
while(inClientFile >> account >>fname>>mname>>lname >> balance )
if (account==number) //I think the problem starts here
cout<<" "<<endl;
else
outClientFile<<account<< ' ' <<fname<< ' ' <<mname<<' '<<lname<<' '<<balance<<' '<<endl;
cout<<"The record has been deleted"<<endl;
}
outClientFile.close();
inClientFile.close();
remove("clients.txt");
rename("clients1.txt","clients.txt");
In my If statement, I want to add a message wherin if the entered account number does not exist in record inside clients.txt, a message will appear saying, "Account number does not exist." but can't figure out how to make it to work, cant someone help me plz..
also could you please help me make my code more clearer. ehe!
thanks!

New Topic/Question
Reply




MultiQuote





|