title: C++ reading buffer size
body: <p>Suppose that this file is 2 and 1/2 blocks long, with block size of 1024. </p>
  
  <pre><code>aBlock = 1024;
  char* buffer = new char[aBlock];
  while (!myFile.eof()) {
      myFile.read(buffer,aBlock);
      //do more stuff
  }
  </code></pre>
  
  <p>The third time it reads, it is going to write half of the buffer, leaving the other half with invalid data. Is there a way to know how many bytes did it actually write to the buffer?</p>