That's writing sal as a binary value to the file rather than converting it to text. Unless there's a specific reason to do so, it's probably not the best thing to do it that way.
Sure it is a good way! Unless there's a specific reason to save your data as text, saving it as binary is quick and easy to load it back... I am being silly though as I usually save program configuration files or just data being used in .xml (tinyxml2) or excel documents (.xlsx)
P.S. You must be opening the file in the 'calculate' class method / function [it isnt clear on which it is] which isn't shown in the code...
Or if your not, that's why it's not writing that to a file:
try adding a:
1 2 3 4 5 6 7 8 9 10 11 12 13
fout.open("C:\\salarydata.bin", std::ofstream::out | std::ofstream::binary);
[code]
before the fout.write line ;)
then use an ifstream to read the file back into &sal something like:
[code]
memset(&sal, 0, sizeof(sal));
ifstream fin;
fin.open("C:\\salarydata.bin", std::ifstream::in | std::ifstream::binary);
fin.read((char*)&sal, sizeof(sal));
fin.close();
you could do that in another instance after you saved it initially and it will load that data back into the program from the file on disk! :)