Advertisement
badlogic

crude c++

Sep 12th, 2019
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.95 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <sstream>
  4. #include <string>
  5.  
  6. cout<<"1 - Add\n";
  7. cout<<"2 - Search\n";
  8. cout<<"3 - List All \n";
  9. cout<<"4 - Edit\n";
  10. cout<<"5 - Delete\n";
  11. cin>>choice;
  12.  
  13. ofstream out("PhoneBook.txt",ios::app);
  14. cout<<"\t\t\t Phone Book";
  15. cout<<"\nEnter the first name: ";
  16. cin>>fname;
  17. cout<<"\nEnter the second name: ";
  18. cin>>lname;
  19. cout<<"\n\nEnter the phone number";
  20. cin>>p_num;
  21.  
  22. de for add record in text(.txt) fileC++
  23. ofstream out("PhoneBook.txt",ios::app);
  24.  
  25. cout<<"\t\t\t Phone Book";
  26. cout<<"\nEnter the first name: ";
  27. cin>>fname;
  28. cout<<"\nEnter the second name: ";
  29. cin>>lname;
  30. cout<<"\n\nEnter the phone number";
  31. cin>>p_num;
  32.  
  33. ofstream out("PhoneBook.txt",ios::app);
  34.  
  35. cout<<"\t\t\t Phone Book";
  36. cout<<"\nEnter the first name: ";
  37. cin>>fname;
  38. cout<<"\nEnter the second name: ";
  39. cin>>lname;
  40. cout<<"\n\nEnter the phone number";
  41. cin>>p_num;
  42.  
  43. w all record code from text(.txt) fileC++
  44.         ifstream data("PhoneBook.txt");
  45.  
  46.         cout<<"Enter the name of the person: ";
  47.         cin>>user_input;
  48.  
  49.             counter = 0;
  50.  
  51.             while( !data.eof() ) {
  52.  
  53.                 getline(data,record);
  54.                 stringstream stream_i(record);
  55.  
  56.                 if (record.find(user_input) != string::npos) {
  57.                      while( getline(stream_i,item_i,',') ) {
  58.                             contact[counter++] = item_i;
  59.                      }
  60.                 }
  61.             }
  62.  
  63.            cout<<"First name:"<<contact[0]<<"\n";
  64.            cout<<"Family name:"<<contact[1]<<"\n";
  65.            cout<<"Phone Number:"<<contact[2]<<"\n";
  66.  
  67.         ifstream data("PhoneBook.txt");
  68.  
  69.         cout<<"Enter the name of the person: ";
  70.         cin>>user_input;
  71.  
  72.             counter = 0;
  73.  
  74.             while( !data.eof() ) {
  75.  
  76.                 getline(data,record);
  77.                 stringstream stream_i(record);
  78.  
  79.                 if (record.find(user_input) != string::npos) {
  80.                      while( getline(stream_i,item_i,',') ) {
  81.                             contact[counter++] = item_i;
  82.                      }
  83.                 }
  84.             }
  85.  
  86.            cout<<"First name:"<<contact[0]<<"\n";
  87.            cout<<"Family name:"<<contact[1]<<"\n";
  88.            cout<<"Phone Number:"<<contact[2]<<"\n";
  89.  
  90.  
  91. Search record code from text(.txt) fileC++
  92. cout<<"Enter the name of the person: ";
  93. cin>>user_input;
  94.                  
  95.                  ifstream data("PhoneBook.txt");
  96.                  
  97.       while( !data.eof() ) {
  98.                        
  99.                         getline(data,record);
  100.                        
  101.             if (record.find(user_input) != string::npos) {
  102.                 cout<<record<<"\n";
  103.             }
  104.  
  105.                  }
  106.  
  107. cout<<"Enter the name of the person: ";
  108. cin>>user_input;
  109.                  
  110.                  ifstream data("PhoneBook.txt");
  111.                  
  112.       while( !data.eof() ) {
  113.                        
  114.                         getline(data,record);
  115.                        
  116.             if (record.find(user_input) != string::npos) {
  117.                 cout<<record<<"\n";
  118.             }
  119.  
  120.                  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement