.  .  Click on the title for the solution  .  .     This is the answer:      :      #include <iostream>  #include <fstream>  #include <string>   using namespace std;   void lookup();  void add();   int main()  {   string type;   while (cin >> type)   {    if (type == "lookup") lookup();    else  add();   }   return 0;  }   void lookup()  {   ifstream fin;   fin.open("phonedir");   if(!fin.is_open()) cout << "Not Open" << endl;    bool check = false;    string name,firstName,lastName,email;    cin >> name;    while (fin >> firstName >> lastName >> email)   {    if (firstName== name || lastName==name)    {     cout<<firstName<<" "<<lastName<<" "<<email<<endl;     check=true;    }   }   if(!check)    cout << name << ": not found" << endl;   fin.close();  }   void add()  {   ofstream fout;   string name;     string fir...
 
Comments
Post a Comment