title: Can't read .exe file in C properly
body: <p>I tried to print out the raw data of an PE file with this C application: </p>
  
  <pre><code>int main(int argc, char *argv[])
      {
      if (argc != 2) 
      {printf("Syntax: &lt;file&gt;\n"); 
      return 0;
      }
      FILE *f = fopen(argv[1], "rb");
      if (f == NULL)
      {
          printf("Open file failed.\n");
          return 0; 
      }
      fseek(f, 0, SEEK_END);
      long fsize = ftell(f);
      fseek(f, 0, SEEK_SET);
      unsigned char *string = (unsigned char*)malloc(fsize + 1);
      fread(string, fsize, 1, f);
      fclose(f);
      string[fsize] = 0;
      printf("File content:\n ");  
      printf("%s", string); 
      return 0;}
  </code></pre>
  
  <p>I compiled it with MinGw gcc:</p>
  
  <pre><code>foo.c -o foo.exe -m32
  </code></pre>
  
  <p>If I pass a text file to <code>foo.exe</code> it prints out the content of that file, but if I try to print out the raw data of an .exe it only gives me the first 3 bytes: MZE. 
  I thought it has something to do with <code>fseek()</code>, it may not find the proper EOF, but after I used the winapi ReadFile to read the file, I got the same results. I know it most likely a stupid mistake, so how to print out the whole file?</p>