title: fread not reading the whole file as expected
body: <p>I'm trying to read a large binary file in C.
  I wrote the following code:</p>
  
  <pre><code>FILE* f1 =  fopen("filename.exe", "rb");
      if(f1 != NULL)
      {
          fseek(f1,0,SEEK_END);
          long l = ftell(f1);
          fseek(f1,0,SEEK_SET);
          char * buf = (char *)malloc(l* sizeof(char));
          int k = fread(buf,sizeof(buf),1,f1);
          if(k != l)
              printf("the file was not read properly");
      }
  </code></pre>
  
  <p>Now, not only is <code>k</code> not equal to <code>l</code>, it is much smaller (<code>l</code> is ~99,000,000 while <code>k</code> is only 13).</p>
  
  <p>Is it possible that <code>fread</code> is stopping because it reaches a NULL in the file? What can I do to avoid it?</p>