Advertisement
Guest User

Task

a guest
Jan 21st, 2013
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. #include <iostream>
  2. #include "conio.h"
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. void main_text()
  8. {
  9.     cout<<"1. Pisane na tekst vuv fail"<<endl;
  10.     cout<<"2. Chetene na celiqt fail"<<endl;
  11.     cout<<"3. Tursene na informaciq"<<endl;
  12.     cout<<"4. End"<<endl;
  13. }
  14.  
  15. int main()
  16. {
  17.     int choice;
  18.     fstream file;
  19.  
  20.     main_text();
  21.     cin>>choice;
  22.  
  23.     do
  24.     {
  25.  
  26.         switch(choice){
  27.         case 1:
  28.             {
  29.                 file.open("data.dat", ios::out);
  30.  
  31.                 char new_entry[100];
  32.  
  33.                 cout<<"Vuvedete si teksta: ";
  34.                 cin.get();
  35.                 cin.getline(new_entry, 100);
  36.  
  37.                 file<<new_entry<<endl;
  38.  
  39.                 file.close();
  40.             }
  41.             break;
  42.         case 2:
  43.             {
  44.                 file.open("data.dat", ios::in);
  45.                 char old_entry[100];
  46.  
  47.                 while (!file.eof())
  48.                 {
  49.                     file>>old_entry;
  50.                     cout<<old_entry<<endl;
  51.                 }
  52.  
  53.                 file.close();
  54.  
  55.                 break;
  56.             }
  57.         case 3:
  58.             {
  59.                 file.open("data.dat", ios::in);
  60.  
  61.                 char entry[100];
  62.                 char search[100];
  63.  
  64.                 cout<<"Koq duma tursite: "; cin>>search;
  65.  
  66.                 while (!file.eof())
  67.                 {
  68.                     file>>entry;
  69.                     if(strcmp(search, entry))
  70.                     {
  71.                         cout<<entry<<endl;
  72.                     }
  73.  
  74.                 }
  75.  
  76.                 file.close();
  77.                 break;
  78.             }
  79.         }
  80.  
  81.         main_text();
  82.         cin>>choice;
  83.     }while(choice != 4);
  84.  
  85.     return 0;
  86.     _getch();
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement