editing saved records in a text file

hie evry1.
so i have this program that i am undertaking.....this project needs to store customer details, edit them and delete them...now i am facing the problem of deriving a code to edit those details.....and if someone has a way out bring me out of this misery...sooo i have pasted my project below for you. thanks in advance



MY CODE

#include <fstream>
#include <iostream>
#include <string>

using namespace std;
int main ()

{

int choice [1];
string name;
string idnumber;
string address;
string surname;
string FileName;
fstream myfile;
string line;






cout<<"================================================================================"<<endl;
cout<<" CUSTOMER DETAILS FILE "<<endl;
cout<<"================================================================================"<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<"******************************************************************************** "<<endl;
cout<<" 1) ADD NEW CUSTOMER "<<endl;
cout <<" "<<endl;
cout<<" 2) EDIT CUSTOMER'S DETAILS "<<endl;
cout<<" "<<endl;
cout<<" 3) DELETE CUSTOMER'S DETAIL "<<endl;
cout <<" "<<endl;
cout <<" 4) VIEW CUSTOMER DETAILS "<<endl;
cout <<" "<<endl;
cout <<" 5) BACK TO MAIN PAGE "<<endl;
cout<<"******************************************************************************** "<<endl;
cout<<" "<<endl;
cout<<" please enter your choice :";
cin>> choice[1];
system("cls");
if (choice [1]==1)



//asking the user to input required data
{
cout <<" "<<endl;
cout <<"================================================================================"<<endl;
cout <<" NEW CUSTOMER "<<endl;
cout <<"================================================================================"<<endl;
cout <<" "<<endl;
cout <<" "<<endl;

cout <<" "<<endl;
cout <<"enter customer name :" ;
cin >> name;


cout <<" "<<endl;
cout <<"enter customer surname :";
cin>>surname;


cout <<" "<<endl;
cout <<"enter customer I.D :";
cin>>idnumber;



cout <<" "<<endl;
cout <<"enter customer aaddress :";
cin>>address;

// saving inputted text

ofstream myfile;
myfile.open ("TBS.txt",ios::out|ios::app);
myfile << name<<'\t'<<surname<<'\t'<<idnumber<<'\t'<<address<<endl;
myfile.close();
system("cls");


cout <<""<<endl;
cout <<"================================================================================ "<<endl;
cout <<""<<endl;
cout <<"*************NEW CUSTOMER DETAILS HAS BEEN ADDED SUCCESFULLY***** "<<endl;
cout <<""<<endl;
cout <<"================================================================================ "<<endl;
}
else if (choice [1]==2)
{

cout <<" "<<endl;
cout <<"================================================================================"<<endl;
cout <<" EDIT CUSTOMER DETAILS"<<endl;
cout <<"================================================================================"<<endl;
cout <<" "<<endl;
cout <<" "<<endl;
}


else if (choice[1]== 4)
{
string getcontent;
ifstream myfile ("TBS.txt",ios::in);
if(myfile.is_open())
{
while( myfile.eof())
{
myfile >> getcontent;
cout << getcontent <<endl;
}
}
}

system("PAUSE>null");
return 0;
}
Topic archived. No new replies allowed.