title: Reading strings and integers from one binary text in C
body: <p>I'm using C and I want to read from a binaryFile.</p>
  
  <p>I know that it is contain strings in the following way:  Length of a string, the string itself, the length of a string, string itself, and so on...</p>
  
  <p>I want to count the number of times which the string Str appears in the binary file.</p>
  
  <p>So I want to do something like this:</p>
  
  <pre><code>int N;
  while (!feof(file)){
      if (fread(&amp;N, sizeof(int), 1, file)==1)
          ...
  </code></pre>
  
  <p>Now I need to get the string itself. I know it's length. Should I do a 'for'
      loop and get with fgetc char by char? I know I'm not allowed to use fscanf since 
      it's not a text file, but can I use fgetc? And would I get what I'm expecting for
      my string? (To use dynamic allocation for char* for it with the size of the length
      and use strcpy to add it to the current string?)</p>