title: Finding all byte positions where two files differ
body: <p>With the following code, I'm able to compare two files and find the start position where they differ but now want to find all the places where they differ and print them out, not just the first place. I know it's a loop but I can't figure out how to do the loop. I thought with leaving the while loop as is and taking the break statement out it would work but it does not.
  How I call it:</p>
  
  <pre><code>            if ((fp1 != NULL) &amp;&amp; (fp2 != NULL)){
                  compare_two_binary_files(fp1, fp2);
                  }
  </code></pre>
  
  <p>How it's implemented:</p>
  
  <pre><code>void compare(FILE *f1, FILE *f2)
  {
      char ch1, ch2;
      int flag = 0;
  
  while (((ch1 = fgetc(f1)) != EOF) &amp;&amp;((ch2 = fgetc(f2)) != EOF)){
      if (ch1 == ch2)
      {
          flag = 1;
          continue;
      }
      /*
       * If not equal then returns the byte position
       */
      else
      {
          fseek(f1, -1, SEEK_CUR);
          flag = 0;
          printf("Byte pos where two files differ is %d\n", ftell(f1)+1);
      break;
      }
  }
  </code></pre>
  
  <p>}</p>