Advertisement Remove all ads

Find the Output of the Following C++ Code Considering that the Binary File School.Dat Exists on the Hard Disk with the Following Records of 10 Schools of the Class Schools as Declared in the Previous Question(4 B) - Computer Science (C++)

Find the output of the following C++ code considering that the binary file SCHOOL.DAT exists on the hard disk with the following records of 10 schools of the class SCHOOLS as declared in the previous question(4 b)

SCode SName NOT
1001 Brains School 100
1003 Child Life School 115
1002 Care Share School 300
1006 Educa t for Life School 50
1005 Guru Shiahya Sadan 195
1004 Holy Education School 140
1010 Play School 95
1008 Innovate Excel School 300
1011 Premier Education School 200
1012 Uplifted Minds School 100
void main()
{
     fstream SFIN;
     SFIN.open("SCHOOLS.DAT", ios::binary|ios::in) ;
     SCHOOLS S;
     SFIN.seekg(S*sizeof(S));
     SFIN.read((char*)&S, sizeof(S));
     S.Display();
     cout<<"Record : "<<SFIN.tellg()/sizeof(S) + l <<endl;
     SFIN.close();
}
Advertisement Remove all ads

Solution

Record: 7

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
Advertisement Remove all ads
Advertisement Remove all ads
Share
Notifications

View all notifications


      Forgot password?
View in app×