title: c++ seekp(0，ios::end) not working
body: <p>Apologize for my poor English.
  I am stuck by <code>fstream</code> in C++. Here is my code.</p>
  
  <pre><code>#include&lt;iostream&gt;  
  #include&lt;fstream&gt;
  using namespace std;
  
  struct TestStruct
  {
      int a;
      char str[30];
      TestStruct(int a_, const char* s)
      {
          a = a_;
          strcpy_s(str,sizeof(char)*30, s);
      }
      TestStruct() = default;
  };
  
  int main()
  {
      fstream output("out.bin", ios::out|ios::binary);
      output.seekp(0,ios::end);
      cout &lt;&lt; output.tellp() &lt;&lt; endl;
  
      for (int i = 0; i &lt; 15; i++) {
          TestStruct a(10*i, "asdadas");
          output.write(reinterpret_cast&lt;char*&gt;(&amp;a), sizeof(a));
      }
  
      output.close();
      fstream input("out.bin", ios::in | ios::binary);
      input.seekg(2 * sizeof(TestStruct), ios::beg);
  
      for (int i = 0; i &lt; 5; i++) {
          TestStruct a;
          input.read(reinterpret_cast&lt;char*&gt;(&amp;a), sizeof(a));
          cout &lt;&lt;"file_pointer"&lt;&lt;input.tellg()&lt;&lt;'\t'&lt;&lt;a.a &lt;&lt; endl;
      }
  }
  </code></pre>
  
  <p>I use <code>seekp(0,ios::end)</code> to add new entry in the file. So the file should get lager when I run this code. But actually the file haven't change at all.</p>
  
  <p>Here is the output:</p>
  
  <pre><code>&gt;     0                  &lt;--tellp() always return 0
  &gt;     file_pointer108 20
  &gt;     file_pointer144 30
  &gt;     file_pointer180 40
  &gt;     file_pointer216 50
  &gt;     file_pointer252 60
  </code></pre>