
On 6 February 2013 00:13, Robert Ramey
Nicholas Mario Wardhana wrote:
int main()
//std::ofstream filename1("binary_serialization.txt"); // error - open in binary mode std::ofstream filename1("binary_serialization.txt", std::ios::binary); boost::archive::binary_oarchive binary_oa(filename1); binary_oa & g; filename1.close(); }
Thank you very much Robert! As the resulting file looked "binary" enough to me, I didn't realise that I missed the std::ios::binary flag when saving the file. Your code solved the problem. As for the portability, I found that there are a few affecting factors, e.g. different variable sizes and processor architectures [1]. However, I just generated the files on an another computer with similar system, and the files are exactly the same as what I previously generated on my computer. The other computer can read the file properly. As I don't target too different architectures, I think I am going to check myself to what extend the binary format is portable. Best regards, Nicholas Mario Wardhana References: [1] http://www.eskimo.com/~scs/cclass/int/sx3b.html