Advertisement Remove all ads

Write a Definition for a Function Totalteachers( ) in C++ to Read Each Object of a Binary File Schools.Dat, Find the Total Number Teachers, Whose Data is Stored in the File and Display the Same. Assume that the File Schools.Dat is Created with the Help Objects of Class Schools, Which is Defined Below : - Computer Science (C++)

Advertisement Remove all ads
Advertisement Remove all ads
Advertisement Remove all ads

Write a definition for a function TotalTeachers( ) in C++ to read each object of a binary file SCHOOLS.DAT, find the total number teachers, whose data is stored in the file and display the same. Assume that the file SCHOOLS.DAT is created with the help objects of class SCHOOLS, which is defined below :

    int SCode;        //School Code
    char SName[20];   //School Name
    int NOT;          // Name of Teachers in the school

    void Display()
       cout<<SCode<<"#"<<SName<<"#" << NOT << endl;
       int RNOT() {return NOT;}
Advertisement Remove all ads


void putnot()
    cout <<NOT<< "  ";

void TotalTeachers()
     fstream f;
     SCHOOLS Stu;"SCHOOLS.DAT", ios::in|ios::binary);
     cout << “\nTotal no. of Teachers : \n”;
     while((*)&Stu, sizeof(Stu))) != NULL)
Concept: Implementation of Basic File Operations on Text and Binary File in C++
  Is there an error in this question or solution?
Advertisement Remove all ads

View all notifications

      Forgot password?
View in app×