title: Edit an existing file in C++
body: <p>I have preferences file for my application in Qt.
  Whenever I launch the application it loads the file &amp; depending the contents creates the widgets accordingly. I have given some customisation option for the user. Now when my application is closed I am checking whether the preferences are changed. If yes then I am opening the preferences file again &amp; then just adding everything again in it. I am not creating a temporary file, I am directly editing the file. Is this method an efficient one? or am I doing it wrong? because I found these threads:
  1. <a href="https://stackoverflow.com/questions/732469/what-is-the-best-way-to-edit-the-middle-of-an-existing-flat-file">What is the best way to edit the middle of an existing flat file?</a></p>
  
  <ol start="2">
  <li><a href="http://qt-project.org/forums/viewthread/25924/" rel="nofollow noreferrer">http://qt-project.org/forums/viewthread/25924/</a></li>
  </ol>
  
  <p>Should use I binary file? Currently I am using ASCII file.
  Thanks.</p>
  
  <p>UPDATE: In the stackoverflow link above the correct answer has</p>
  
  <blockquote>
    <p>If you're stuck using flat, then you're stuck using the old fashioned
    way of updating them</p>
  </blockquote>
  
  <p>I meant to ask whether the method I am using is old fashioned &amp; is there a better method used nowadays? &amp; what does flat file mean?</p>