   [C++] writing structs to binary files
  I've got a struct with a pointer to another struct inside it.  How do I use fwrite to save it?struct Stuff{    float x, y, z;};struct MyStructure{    Stuff* myStuff;};MyStructure test;test.myStuff = new Stuff[100];[fill myStuff with data]FILE *fp;fp = fopen("myfile.extension","wb");fwrite(test, sizeof(test), 1, fp);[except nothing is being written to the file, and yes, test.myStuff does have information in it]fclose(fp);
  In C++, we use the class ofstream from the fstream header to write files. When writing the contents of a structure or class to disk, the process is referred to as serialization. You can find all the information you need here.   ;  You simply forgot the '&', and also inverted the 2nd and 3rd parameters, you want to do this instead:fwrite(&test, 1, sizeof(test), fp);   