title: Reading .wav files - Not reading header?
body: <p>I am trying to read the header information from a .wav file, and I'm reading the following properties of the file:</p>
  
  <pre><code>    type 
      size
      Format Tag
      Format Length
      Channels
      Sample Rate
      Average Bytes Second
      Block Align
      Bits Per Sample
      Data size
  </code></pre>
  
  <p>Now, everything reads perfectly up until reading in Sample Rate, then, the output is either "0" value or just NULL. </p>
  
  <p>Here is the code: (I have opened the text file, and passed the pointer to the member function)</p>
  
  <pre><code>bool Wav::readHeader(FILE *dataIn)
  {
     char type2[4];
     fread(this-&gt;type, sizeof(char), 4, dataIn);
  
     fread(&amp;this-&gt;size, sizeof(int), 1, dataIn);
  
     fread(this-&gt;type, sizeof(char), 4, dataIn);
  
     fread(this-&gt;type, sizeof(char), 4, dataIn);
  
     fread(&amp;this-&gt;format_length, sizeof(short), 1, dataIn);
  
     fread(&amp;this-&gt;format_tag, sizeof(short), 1, dataIn);
  
     fread(&amp;this-&gt;channels, sizeof(short), 1, dataIn);
  
  
     fread(&amp;this-&gt;sample_rate, sizeof(unsigned int), 1, dataIn);
  
     fread(&amp;this-&gt;avg_bytes_sec, sizeof(unsigned short), 1, dataIn);
  
     fread(&amp;this-&gt;block_align, sizeof(short), 1, dataIn);
  
     fread(&amp;this-&gt;bits_per_sample, sizeof(short), 1, dataIn);
  
     return true;
  }
  </code></pre>
  
  <p>And the class members are defined as:</p>
  
  <pre><code>    char type[4]; 
      int size;
      unsigned short format_tag;
      unsigned short format_length;
      unsigned short channels;
      unsigned int sample_rate;
      unsigned short avg_bytes_sec;
      unsigned short block_align;
      unsigned short bits_per_sample;
      unsigned int data_size;
  </code></pre>
  
  <p>Does anyone have any solutions or suggestions?</p>
  
  <p>(P.S. Apologies if this question is not right. I have tried to write it the best I could!)</p>