title: What is the most elegant way to write a text/binary file with c++?
body: <p>I found some good results on reading e.g.: <a href="https://stackoverflow.com/questions/2602013/read-whole-ascii-file-into-c-stdstring">Read txt with iterators and preallocation</a>, or <a href="https://stackoverflow.com/questions/195323/what-is-the-most-elegant-way-to-read-a-text-file-with-c">read into containers</a>. So I wondered how would I write most elegant a std::string into a file?</p>
  
  <p>Edit: When reading I can preallocate space for the string via seek and tellg, since I know the size of the string, how could I tell the filesystem how much I want to write?</p>