title: Why is fseek or fflush always required between reading and writing in the update modes?
body: <blockquote>
    <p>Q: I'm trying to update a file in
    place, by using <code>fopen</code> mode <code>"r+"</code>,
    reading a certain string, and writing
    back a modified string, but it's not
    working.</p>
    
    <p>A: Be sure to call <code>fseek</code> before
    you write, both to seek back to the
    beginning of the string you're trying
    to overwrite, and <strong>because an <code>fseek</code>
    or <code>fflush</code> is always required between
    reading and writing in the read/write
    "+" modes.</strong></p>
  </blockquote>
  
  <p>My question is <strong>why</strong> <code>fseek</code> or <code>fflush</code> is always required between reading and writing in the read/write "+" modes?  Section 5.2 of 
  Andrew Koenig's
  <a href="https://rads.stackoverflow.com/amzn/click/com/0201179288" rel="noreferrer" rel="nofollow noreferrer">C Traps and Pitfalls</a> (1989) mentioned that it is because of a backward compatibility issue. Can anyone explain in detail?</p>