   Saving a network to a file?
  Hi, I have a game partly designed.  I have a network consisting of nodes with pointers between them.  I store the nodes in a vector object and each node object also contains a vector of pointers to other node objects to which a node connects.  My question is, is there an easy way of saving such a structure to a file?  Since each time a programme is run, it uses a diffrent chunk of memory.  Am I right thinking if I simpley streamed all the pointers to a file, when I re-loaded the pointers would no longer point to the corrent objects?   
  You can't save the pointers to a file.What you'd need to do is give each object a unique ID, then save those to a file. Then you'd need to reload the nodes, then do a second pass, reconnecting all the pointers to the appropriate IDs afterwards.Mark   ;  Ah, thanks alot.   ;  If you store them in a single STL vector object, why not use indexes into the vector instead of pointers? Indexes don't need to change after successive runs, so it can be easily written to/loaded from a file. This is how I store a BSP tree in a file, for example.   ;  I did think about that but what would happen if I deleted a node from the middle of the vector?  Would that not change the index of all the items above the deleted item and screw the whole thing up?   ;  Yes it would.If you realy need to delete "nodes" from the vector, markr's suggestion is a better idea.However, even if you use markr's method, you still need to traverse the vector and make sure no nodes reference the recently deleted node...   