title: Read the full content of a binary file
body: <p><br />
  I have this piece of <b>C</b> code:</p>
  
  <pre><code>[...]
  struct stat info;
  char *filename = "just_a_binary_file";
  stat(filename, &amp;info);
  printf("FILE SIZE: %d\n", info.st_size);
  
  char *content = (char *)malloc(info.st_size * sizeof(char *));
  FILE *fp = fopen(filename, "rb");
  fread(content, info.st_size, 1, fp);
  fclose(fp);
  
  printf("STRING LENGTH: %d\n", strlen(content));
  [...]
  </code></pre>
  
  <p>the output is:</p>
  
  <pre><code>FILE SIZE: 20481
  STRING LENGTH: 6
  </code></pre>
  
  <p>the problem is that file contains some Zero-Bytes and when I put the file content into a variable char* the string is truncated at the first occurrence of '\0' (chr(0) precisely).</p>
  
  <p>The question is how can I get the full binary content into a variable char*?</p>