Maintaining STUDENT records in a file - C++ Program

#include<iostream.h>
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
#include<ctype.h>
class student
{
   char name[30];
   int rollno;
   int marks;
   public:
    void input()
    {
       cout<<"\nEnter Name   : ";
       gets(name);
       cout<<"\nEnter Rollno : ";
       cin>>rollno;
       cout<<"\n Enter Marks : ";
       cin>>marks;
    }
    void display()
    {
       cout<<"\n"<<name<<"\t"<<rollno<<"\t"<<marks;
       if(marks>=96)
  cout<<"\tComputer SC";
       else if(marks>=91&&marks<90)
  cout<<"\tElectronics";
       else if(marks>=86&&marks<=90)
  cout<<"\tMechanical";
       else if(marks>=81&&marks<=85)
  cout<<"\tElectrical";
       else if(marks>=76&&marks<=80)
  cout<<"\tChemical";
       else if(marks>=71&&marks<=75)
  cout<<"\tCivil";
       else
  cout<<"\tNone";
    }
};
    void main()
    {
       clrscr();
       student s;
       int i, j, n, ch;
       fstream ofile, afile;
       char ch1;
       do
       {
   clrscr();
   cout<<"\n----MENU----";
   cout<<"\n1.Add Record\n2.Show Record"
       <<"\n3.Exit";
   cout<<"\nEnter your choice : ";
   cin>>ch;
   switch(ch)
   {
      case 1: ofile.open("ST.dat",ios::app|ios::binary);
       cout<<"\nEnter number of records to be entered : ";
       cin>>n;
       for(i=0;i<n;i++)
       {
          s.input();
          ofile.write((char *)&s,sizeof (s));
       }
       ofile.close();
       break;
      case 2: cout<<"\nName\tRollno\tMarks\tStream";
       afile.open("ST.dat",ios::in|ios::binary);
       while(afile)
       {
          afile.read((char *)&s,sizeof (s));
          if(!afile)
          break;
          s.display();
       }
       afile.close();
       break;
      case 3: exit(0);
     default: cout<<"\nWrong choice!!!";
    }
    cout<<"\nPress any key to cotinue";
    getch();
   }while(1);
        }

32 comments:

  1. Informative blog ... Thnq for sharing your thoughts with us .. keep going..

    Selenium training | Selenium training in chennai

    ReplyDelete
  2. Thank you for sharing such valuable information and tips. This can give insights and inspirations for us; very helpful and informative! Would love to see more updates from you in the future.
    Best QTP Training Center in Chennai
    UFT Training in Chennai
    performance testing training in chennai
    hp loadrunner training
    selenium course
    selenium Training in Chennai

    ReplyDelete
    Replies
    1. http://www.mestutors.com/2014/09/maintaining-student-records-in-file-c.html

      Delete
  3. Thanks for splitting your comprehension with us. It’s really useful to me & I hope it helps the people who in need of this vital information.
    PHP Training in Chennai
    PHP Course in Chennai
    PHP Training Institute in Chennai
    PHP course
    PHP Training

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Nice post. I learned some new information. Thanks for sharing.

    Education
    Technology

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. Really i found this article more informative, thanks for sharing this article! Also Check here

    Download and install Vidmate App which is the best HD video downloader software available for Android. Get free latest HD movies, songs, and your favorite TV shows

    Vidmate App Download

    Vidmate apk for Android devices

    Vidmate App

    download Vidmate for Windows PC

    download Vidmate for Windows PC Free

    Vidmate Download for Windows 10

    Download Vidmate for iOS

    Download Vidmate for Blackberry

    Vidmate For IOS and Blackberry OS

    ReplyDelete
  8. Your Website is very good, Your Website impressed us a lot, We have liked your website very much.
    We have also created a website of Android App that you can see it.

    http://damodapk.com/

    ReplyDelete
  9. Trade Stocks, Forex, And Bitcoin Anywhere In The World: roboforex login Is The Leading Provider Of Software That Allows You To Trade On Your Own Terms. Whether You Are Operating In The Forex, Stock, Or Cryptocurrency Markets, Use roboforex login Software And Anonymous Digital Wallet To Connect With The Financial World.: roboforex login Is A Currency Trading Company That Allows You To Trade Stocks, Forex, And Cryptocurrency.

    ReplyDelete
  10. hi thanku so much this infromation thanku so much
    bluehost-discounts
    milesweb-review

    ReplyDelete
  11. OctaFx Review helps identify trading opportunities using actions of Market Participants through charts, patterns, and indicators. It seeks to answer the question: "How Will Market Participants React To Current And Future Events?"

    ReplyDelete
  12. Is There A Link That You Could Share That Would Give Us A More Detailed Rundown On How Fxtm Review Works ?

    ReplyDelete
  13. VT Markets Provides Traders With The Best Possible Trading Conditions—from Low Minimum Deposit Demands To Tight Spreads And Fast Trade Execution Speeds. Read More Here.

    ReplyDelete
  14. That Is Very Interesting, You’re An Excessively Professional Blogger. I Have Joined Your Feed And Sit Up For Searching For More Of Your VT Markets Wonderful Post. Also, I’ve Shared Your Web Site In My Social Networks

    ReplyDelete
  15. Forex Broker Nigeria Forex Broker USA Top List Of Forex Brokers By Country. Compare Forex Brokers, Forex Trading Platforms & Forex Indicators.

    ReplyDelete
  16. Very Informative blog thank you for sharing. Keep sharing.

    Best software training institute in Chennai. Make your career development the best by learning software courses.

    azure training in chennai
    Docker Training in Chennai
    devops training in chennai

    ReplyDelete
  17. I liked your content its so usefull for me. i am also a blogger and im also writting this kind of content . please check it and give me your suggestion
    Jaisana


    ReplyDelete