#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
struct inventory {
char item[20];
int quantity;
double cost;
};
int main(int argc, char *argv[])
{
inventory entry;
long record_num = 2;
ifstream fInvDB("InvDat.dat", ios::in | ios::binary);
if(!fInvDB) {
cout << "Cannot open file.\n";
return 1;
}
fInvDB.seekg(sizeof(inventory) * record_num, ios::beg);
fInvDB.read((char *) &entry, sizeof(inventory));
fInvDB.close();
if(!fInvDB.good()) {
cout << "A file error occurred.\n";
return 1;
}
}
|