title: Reading and manipulating a WAV file in C++
body: <p>I'm trying to write a simple program to read a WAV file in C++ and get data like sample rate and bit depth. At some point I want to use this to manipulate the data to create an audio plugin, but I want to understand this first.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;fstream&gt;
  #include &lt;ostream&gt;
  using namespace std;
  
  struct wavfile {
      char   id[4];
      int    totallength;
      char   wavefmt[8];
      int    format;
      short  pcm;
      short  channels;
      int    frequency;
      int    bytes_per_second;
      short  bytes_by_capture;
      short  bits_per_sample;
      char   data[4];
      int    bytes_in_data;
  };
  
  int main () {
      FILE * wfile;
      std::ofstream ofs;
      wfile = ofs.open("tes.wav",std::ofstream::binary | std::ofstream::app); // line 31
  
      ofs.close();
  
  return 0;
  }
  </code></pre>
  
  <p>When I try to run it it keep saying "assigning to 'FILE *' (aka '__sFILE *') from incompatible type 'void'" </p>
  
  <p>How can I get it to open the wave file, read the data, so I can define it as a within the struct wavfile and print it back out?</p>
  
  <p>Any help would be greatly appreciated, even just pointing me in the right direction or to a good resource. Thanks in advance!</p>