Sunday 9 September 2012

File structures program to check HEX DUMP

#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
  class student
    {
      public:char name[10];
         int rollno,marks,attendence;

          void getdata()
           {
           cout<<"enter student name:"<<endl;
           gets(name);
           cout<<"enter student rollno:"<<endl;
           cin>>rollno;
           cout<<"enter student marks:"<<endl;
           cin>>marks;
           cout<<"enter student attendence:"<<endl;
           cin>>attendence;
          }
        };
      int main()
        {
          char ch;
          clrscr();
          student s;
          fstream f;
          f.open("le.rec",ios::out|ios::trunc);
          int n;
          cout<<"enter how many records do u want:"<<endl;
          cin>>n;
          for(int i=0;i<n;i++)
        {
          s.getdata();
          f<<s.name;
          f<<s.rollno;
          f<<s.marks;
          f<<s.attendence;
        }
        f.close();
        fstream f1;
        f1.open("le.rec",ios::in);
         cout<<"records are:"<<endl;
         while(f1)
        {
          f1.get(ch);
          int m=toascii(ch);
          printf("%x  ",m);
        }
        f.close();
        getch();
        return 0;
       }


Output:

No comments:

Post a Comment