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?
APPEARS IN
Advertisement Remove all ads