Hello, I am trying to write data to a binary file. The function runs (the cout << "TEST" shows me that my loop is running the correct amount of times), but after the program comes to the end, it crashes and doesn't save the data to the binary file. Can anybody see what I am doing wrong?? Any tips/ nudges in the right direction would be appreciated. Thanks!
void Save_Data(int seats[][NUM_SEATS_PER_ROW])
{
int row;
char seatLetter;
seats[NUM_ROWS][NUM_SEATS_PER_ROW];
enum seatStatus {empty, reserved, purchased};
seatStatus status;
fstream binFile;
binFile.open ("PLANE.bin", ios::binary | ios::out | ios::in);
for (row = 0; row <= NUM_ROWS; row ++)
{
for (seatLetter = 'A'; seatLetter <= 'F'; seatLetter++)
{
if (seats[row][seatLetter] != empty)
{
binFile.write(reinterpret_cast<const char*>(row), sizeof(int));
binFile.write(reinterpret_cast<const char*>(seatLetter), sizeof(char));
binFile.write(reinterpret_cast<const char*>(&seats[row][seatLetter]), sizeof
(seatStatus));
}
}
}
binFile.close();
} // End of function