Good afternoon, I have a structure
struct bird{ string name; string type; string habitat; bool migrant; bird *next; };
I need to write it to a file, and then extract it. I write like this (write):
bird bTemp; ofstream output_file("Bird", ios::trunc); else { while(fTemp != NULL) { output_file.write((char*)&bTemp, sizeof(bird)); } }
Extract
void ReadListFromFile() { bird bTemp; ifstream input_file("Bird"); if (!input_file.fail()) { input_file.read((char*)&bTemp, sizeof(bird)); } }
As a result, a binary file is created, but a segmentation error occurs when trying to read