Re: Opening a file in binary
Quote:
Originally posted by niudago
infile.read(0, sizeof(records));
The first argument is where you will store the data being read. 0 means a NULL poi nter, which seems wrong.
Also, always check if the open methods fails or not.
Code:
typedef struct RECORDS *whatever*
...
const int NrOfRecords = 12;
RECORDS MyRecords[NrOfRecords];
InFile.open("Filename.sav", ios::in | ios::binary);
if(!InFile.fail())
{
InFile.read((char*)MyRecords, sizeof(RECORDS) * NrOfRecords);
InFile.close();
}