title: Using visual studio C++ trying to copy the data part of a WAV file using ifstream::read(). The stream jumps around weirdly
body: <p>This is the first code I used:</p>
  
  <pre><code>ifstream wavFile;
  wavFile.open("saxaphone.wav");
  char buffer[10000];
  wavFile.seekg(44);  //data starts at the 44 byte of a wav file
  wavFile.read(buffer, 10000);  
  //file has more than 13000 data bytes so there should
  //be plenty to fill the buffer
  </code></pre>
  
  <p>When I played this buffer with the windows waveOut API it only played coherent sound for about 5000 of the buffer values.</p>
  
  <p>This is the code I used to try and debug:</p>
  
  <pre><code>ifstream wavFile;
  wavFile.open("saxaphone.wav");
  char buffer[10000];
  wavFile.seekg(44);  //data starts at the 44 byte of a wav file
  for(unsigned int i = 0; i &lt; 10000; i++){
       wavFile.read(&amp;buffer[i], 1);
       cout &lt;&lt; wavFile.tellg() &lt;&lt; '\n';
  }
  </code></pre>
  
  <p>This output values from 45 to somewhere in the 4000s before it jumped up to somewhere in the 8000s then started counting by 1 again.  I tried different files to see if that was the problem and it does the same thing.  How do I fix this?</p>