title: Decoding Binary via fget / buffer string (Trying to get mp3 header)
body: <p>I'm writing some quick code to try and extract data from an mp3 file header.</p>
  
  <p>The objective is to extract information from the header such as the bitrate and other vital information so that I can appropriately stream the file to a mp3decoder with the necessary arguments.</p>
  
  <p>Here is a wikipedia image showing the mp3header information:
  <a href="http://upload.wikimedia.org/wikipedia/commons/0/01/Mp3filestructure.svg" rel="nofollow noreferrer">http://upload.wikimedia.org/wikipedia/commons/0/01/Mp3filestructure.svg</a></p>
  
  <p>My question is, am I attacking this correctly? Printing the data received is worthless -- I just get a bunch of random characters. I need to get to the binary so that I can decode it and determine vital information.</p>
  
  <p>Here is my baseline code:</p>
  
  <pre><code>// mp3 Header File IO.cpp : Defines the entry point for the console application.
  //
  
  #include "stdafx.h"
  #include "stdio.h"
  #include "string.h"
  #include "stdlib.h"
  
  // Main function
  int main (void)
  {
      // Declare variables
      FILE *mp3file;
      char *mp3syncword; // we will need to allocate memory to this!!
      char requestedFile[255] = "";
      unsigned long fileLength;
  
      // Counters
      int i;
  
      // Memory allocation with malloc
      mp3syncword=(char *)malloc(2000);
  
      // Let's get the name of the requested file (hard-coded for now)
      strcpy(requestedFile,"testmp3.mp3");
  
      // Open the file with mode read, binary
      mp3file = fopen(requestedFile, "rb"); 
      if (!mp3file){
           // If we can't find the file, notify the user of the problem
           printf("Not found!");
      }
  
      // Let's get some header data from the file
      fseek(mp3file,1,SEEK_SET);
      fread(mp3syncword,32,1,mp3file);
  
      // For debug purposes, lets print the received data
       for(i = 0; i &lt; 32; ++i)
          printf("%c", ((char *)mp3syncword)[i]);
      enter code here
      return 0;
  }
  </code></pre>
  
  <p>Help appreciated.</p>