#include <cstdlib> #include <iostream> #include <fstream> using namespace std; class phonebook { public : char Phone_Number [20]; char First_Name [20]; char last_Name [20]; char Adress [20]; char City [20]; char Email [20]; }; void insert () { phonebook p ; ofstream myfile ; myfile.open("E:\\test.txt",ios::app); cout << "Enter Phone Number " ; cin>> p.Phone_Number; myfile << p.Phone_Number<<'|'; cout<<endl; cout<<"Enter First Name " ; myfile <<p.Phone_Number<<'|'; cin>> p.First_Name; cout<<endl; cout<<"Enter Last Name " ; cin>>p.last_Name; myfile << p.last_Name<<"\n"; cout<<endl; myfile.close(); } void Display () { fstream myfile ; myfile.open("E:\\test.txt",ios::in); phonebook p ; while(!myfile.eof()) { myfile.getline(p.Phone_Number,20,'|'); cout <<p.Phone_Number<<"|"; myfile.getline(p.First_Name,20,'|'); cout<<p.First_Name<<"|"; myfile.getline(p.last_Name,20,'|'); cout<<p.last_Name<<"\n"; cout<<"\n"; }; } void Search (char key[]) { ifstream myfile; myfile.open("E:\\test.txt",ios::in); } int main(int argc, char *argv[]) { insert(); Display(); system("PAUSE"); return EXIT_SUCCESS; } |
|
|