Advertisement
abhask

prog in filehandling to search,remove binary file

Jul 31st, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include<fstream.h>
  2. #include<conio.h>
  3. #include<stdio.h>
  4. #include<ctype.h>
  5. class a
  6. {
  7. private:
  8.     char name[10];
  9.     int rno;
  10.     int s;
  11. public:
  12.     void input()
  13.     {
  14.     cout<<"enter name";
  15.     gets(name);
  16.     cout<<"enter rollno";
  17.     cin>>rno;
  18.     }
  19.      void display()
  20.      {
  21.        puts(name);
  22.        cout<<rno;
  23.      }
  24.      void search()
  25.      { cout<<"enter the roll no. to be searched:";
  26.        cin>>s;
  27.        if(s==rno)
  28.        {
  29.        cout<<"roll no found";
  30.        }
  31.        else
  32.        {
  33.        cout<<"not found";
  34.        }
  35.      }
  36.  
  37. };
  38.  
  39. void main()
  40. {       clrscr();
  41.     a obj;
  42.     //obj.input();
  43.     //obj.display();
  44.     //
  45.     obj.search();
  46.     remove("file.txt");
  47.     ofstream ofile;
  48.     ofile.open("file.txt",ios::app);
  49.     ofile.write((char*)&obj,sizeof(obj));
  50.     ofile.close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement