I have been working a while with saving and retrieve structs, and I still have not got it to work. I get Segmentation fault sh "${SHFILE} . I have search this error, and it has something to do with memory, but I have no idea what, since I am a beginner with saving and retrieving files. The project runs fine, and the error stated above outputs into my console window as text.
filep's value is undeterminate and attempting to dereference or use it might cause segfault.
You wont really need to do this, you can simply use :
1 2 3 4 5 6 7 8 9 10
fbook save;
save.counter = counter;
save.initial = initial;
save.book = checkbook;
ofstream outfile (path.c_str(), ios::binary | ios::out); // i think u can simply use path in C++11
outfile.write((char*)&save, sizeof(save)); // sizeof can take a type
outfile.close(); // <--destructor of ofstream automatically does this