title: Read file into memory?
body: <p>I can seem to only read file into memory if I explicitly declare the buffer size. This works</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  int main(){
    FILE *fp = fopen("test.log", "rb");
    char buffer[37];
    fread(buffer, 1, 36, fp);
    printf("%s", buffer);
  }
  </code></pre>
  
  <p>This will add junk to the output</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  int main(){
    FILE *fp = fopen("test.log", "rb");
    fseek(fp, 0, SEEK_END);
    long siz = ftell(fp);
    rewind(fp);
    char buffer[siz + 1];
    fread(buffer, 1, siz, fp);
    printf("%s", buffer);
  }
  </code></pre>