hie guys could anyone help me on how i can read a delimited file as i view all customer details
#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;
}
\\ function to view all details
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;
}
tyggagucci 0 Newbie Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.