@ceruleus
These worked one by one for the chars in the struct, but I'm still not getting the right info for the doubles...
'
1 2 3 4 5 6 7 8 9 10
|
labfile.read(reinterpret_cast<char*>(&EmployeeRecord.firstname), sizeof(EmployeeRecord.firstname));
labfile.read(reinterpret_cast<char*>(&EmployeeRecord.lastname), sizeof(EmployeeRecord.lastname));
labfile.read(reinterpret_cast<char*>(&EmployeeRecord.idnumber), sizeof(EmployeeRecord.idnumber));
labfile.read(reinterpret_cast<char*>(&EmployeeRecord.datehired), sizeof(EmployeeRecord.datehired));
This didnt work
labfile.read(reinterpret_cast<char*>(&EmployeeRecord.payrate), sizeof(EmployeeRecord.payrate));
labfile.read(reinterpret_cast<char*>(&EmployeeRecord.hoursworked), sizeof(EmployeeRecord.hoursworked));
|
Still getting weird info for payrate and hoursworked(looks like 3.43597e+010), when it should return in values of payrate(999.99) and hoursworked(99.9)
..............
@andy this is the info he gave us, along with a pdf file that says what he wants us to do in the assignment and a bin file(testemployees.bin).
He said-
"For you information, in case you need it, I used the following character counts for the char array string values in the structure used to create the binary data file. It should not matter, but I want you to have the details just in case."
first name and last name: 12+1 (13) <-- that means a maximum of 12 characters + 1 for the NULL
id: 11+1 (12)
date hired: 8+1 (9)
pay rate: float
hours worked: float
And the pdf. file with the assignment says:
"Use the structure definition from lab 4(that's the struct I'm using) that represents the employee data type. Declare a Single object variable and name it employeerecord. Write a looping control structure to read data, one record at a time, into this employeerecord variable. NOTE: The data file I created is a binary data file(testemployees.bin)."
The assignment asks me to do other stuff after that but I can't even get the data to read properly into the struct. Been trying to find a solution for days now but I can't figure it out. If not then i'll just have to wait until after a test tomorrow to ask him about it, but i'm a bit worried about something like this showing up on the test.