title: Trying to write and read a struct that have string an other vaiable types in C++
body: <p>Here is my struct:</p>
  
  <pre><code>struct SV {
  string masv;
  string ho, ten, gioitinh;
  string malop;
  float ds_diem[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
  </code></pre>
  
  <p>As you can see it have a few string and an array of float. I've tried to write and load it using these code:</p>
  
  <p>Write:</p>
  
  <pre><code>fout.write((char *)&amp;dssv[i],sizeof(SV));
  </code></pre>
  
  <p>Read:</p>
  
  <pre><code>fin.read((char *)&amp;sv,sizeof(SV));
  </code></pre>
  
  <p>They didn't work obviously. And i think it have to do something with char and string. I do try to search for solution, but the codes that posted by the asker are to complex for my to understand a single line, let alone the answer. So a simple and genuine answer would be very appreciated.</p>
  
  <p>PS: Forgot to mention I saved it as a .dat file.</p>