QuesAns Print Page – CSKC
Sign In

Search

siteicon
Q&A CBSE12A-2019-A04C-C1 #7030

Question:

Find the output of the following C++ code considering that the binary file STOCK.DAT exist on the hard disk with the following 5 records for the class Stock containing Name and Price .

Name Price
Rice 110
Wheet 60
Cheese 200
Pulses 200
Sauce 150
void main()
{
  fstream FileΒ 
  File.open("STOCK.DAT,ioc::binary|ios::in);
  Stock S;
  for (int I=1; I<=2; I++)
  {
    File.seekg((2*I-1)*sizeof(S));
    File.read((char*)&S, sizeof(S));
    cout<<"Read:"<<File.tellg()/sizeof(S)<<endl;
  }
  File.close();
}