title: Binary file write problem in C++
body: <p>This is my function which creates a binary file</p>
  
  <pre><code>void writefile()
  {
      ofstream myfile ("data.abc", ios::out | ios::binary);
      streamoff offset = 1;
      if(myfile.is_open())
      {
          char c='A';
          myfile.write(&amp;c, offset );
          c='B';
          myfile.write(&amp;c, offset );
          c='C';
          myfile.write(&amp;c,offset);
          myfile.write(StartAddr,streamoff (16) );
          myfile.close();
      }
       else
           cout &lt;&lt; "Some error" &lt;&lt; endl ;
  }
  </code></pre>
  
  <p>The value of StartAddr is <code>1000</code>, hence the expected output file is:
  <code>A B C 1000 NUL NUL NUL</code></p>
  
  <p>However, strangely my output file appends this:  <code>data.abc</code></p>
  
  <p>So the final outcome is: <code>A B C 1000 NUL NUL NUL data.abc</code></p>
  
  <p>Please help me out with this. How to deal with this? Why is this strange behavior?</p>