title: Loading/Saving from file c++ (serialization?)
body: <p>I'm doing home works and our task is to do "Library system"
  I got stuck at saving/loading books from file.</p>
  
  <pre><code>void Library::save() {
  std::ofstream file(fileName);
  if (file.is_open()) {
      for (auto &amp;b : books) {
          std::stringstream ss;
          std::stringstream genres;
          for (auto &amp;g : b.getGenres())
              genres &lt;&lt; g;
  
          ss &lt;&lt; b.getName() &lt;&lt; b.getAutor() &lt;&lt; b.getMajor() &lt;&lt; genres.str() &lt;&lt; b.getBorrowed() &lt;&lt; "\n";
          file &lt;&lt; ss.str();
      }
      file.close();
  }
  
  
  void Library::load() {
  std::streampos size;
  char *memblock;
  
  std::ifstream file(fileName, std::ios::in | std::ios::binary | std::ios::ate);
  if (file.is_open()) {
      size = file.tellg();
      memblock = new char[size];
      file.seekg(0, std::ios::beg);
      file.read(memblock, size);
      file.close();
  
      printf(memblock);
      std::cout &lt;&lt; sizeof(memblock);
  
  
      delete[] memblock;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>When I load it is all in row, how do I separte them? or I have done this all wrong?</p>