I'm trying to write to a binary file from a 1D array while searching for a specific enumerated type. What I need to write to the file are both indexes as well as the enumerated type (int value, in this case 1) I'm pretty sure this for loop isn't working and am wondering if someone can eyeball it and tell me what I am missing or if I am way off the mark..
Code:
status = reserved;
int temp = 1; //reserved status of 1
int indx1 = 0;
int indx2 = 0;
fstream numFile;
numFile.open("PLANE.BIN", ios::binary | ios::out);
for (indx1 = 0; indx1 < 15; indx1++)
for (indx2 = 0; indx2 < 6; indx2++)
if (seatArray[indx1][indx2] == status){
numFile.write( reinterpret_cast<char*>(&seatArray[indx1]), sizeof(int) );
numFile.write( reinterpret_cast<char*>(&seatArray[indx2]), sizeof(int) );
numFile.write( reinterpret_cast<char*>(&temp), sizeof(int) );
}
numFile.close();
Thanks,
Bill