//setting the values of tool names, quantity, cost, and record number
hardware.setNameOfTools (nameOfTools);
hardware.setQtyOfTools (qtyOfTools);
hardware.setCostOfTools (costOfTools);
//seek position in file of user-specified record
outHardware.seekp ( (hardware.getRecNum() -1) * sizeof (hardware));
//write user-specified information in file
outHardware.write (reinterpret_cast < const char * > (&hardware),
sizeof (hardwareData) );
//enables the user to enter another item.
cout << "Enter Record Number. (Enter 0 to end input.)" << endl << endl;
}//end while
Here's the problems I found:
1. You were declaring a constructor that accepted 4 values but never defined what the constructor did with those and then just set the values inside the main body of the code anyways.
2. You never defined the size of a record, nor applied where a record would be so it never knew where to write and where not to. The first time I ran it I got a hardware.dat that was 180MB o.O;
3. After the first run, you didn't ask for a new record number so it was stuck in the loop of writing in the same place and never letting you exit the program.
4. Didn't close the file at the end. Technically, you don't have to but I HIGHLY suggest it.