Using fread/fwrite for STL string. Is it correct?
问题 I have a structure, that contain string. Something like that: struct Chunk { int a; string b; int c; }; So, i suppose, that i cannot write and read this structure from file using fread and fwrite functions. Because string may reserve different memory capacity. But such code works correctly. Chunk var; fwrite(&var, sizeof(Chunk), 1, file); fread(&var, sizeof(Chunk), 1, file); Is there really some problems in it? 回答1: You are justified in doubting this. You should only stream POD types with