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);
        }

28 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. 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
  8. 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
  9. Is There A Link That You Could Share That Would Give Us A More Detailed Rundown On How Fxtm Review Works ?

    ReplyDelete
  10. 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
  11. 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
  12. Forex Broker Nigeria Forex Broker USA Top List Of Forex Brokers By Country. Compare Forex Brokers, Forex Trading Platforms & Forex Indicators.

    ReplyDelete
  13. 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
  14. 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
  15. goood
    Now, it is possible to view saved wifi passwords on your android device like Mobile, Tablet, ChromeOS etc.
    For this purpose, you need to Open the Settings app.
    Go to Network & internet (or Connections) and tap Wi-Fi (or Internet on Android 12 and later).
    Select the current Wi-Fi network you're connected to, or tap Saved networks to choose a different one.
    Tap the Share button.
    Authenticate yourself using your PIN, fingerprint, or face recognition.
    The password will be displayed below a QR code.
    Now, how to decode the QR Code Online, QR Decoder Online will help you to do that very easily by following steps. Regards [ZUCNEE]

    ReplyDelete