title: Weird spaces when iterating through a file in C language
body: <p>Good day, here's my code :</p>
  
  <pre><code>FILE* fp;
  fp = fopen("a.txt","r+");
  if (fp != NULL){
      int c = 0;
      while(!feof(fp)) {
          char k = fgetc(fp);
          if (k == '$') {
              c = 0;
              printf("inside '%c' %d\n", k, c);
              continue;
          }
          c++;
          printf("outside '%c' %d\n", k, c);
      }
  </code></pre>
  
  <p>This is the file :</p>
  
  <blockquote>
    <p>123456$test$pan$test$</p>
  </blockquote>
  
  <p><strong>The output :</strong></p>
  
  <p>outside '1' 1<br>
  outside '2' 2<br>
  outside '3' 3<br>
  outside '4' 4<br>
  outside '5' 5<br>
  outside '6' 6<br>
  ' 7side ' //* <br>
  inside '$' 0<br>
  outside 't' 1<br>
  outside 'e' 2<br>
  outside 's' 3<br>
  outside 't' 4<br>
  ' 5side ' //* <br>
  inside '$' 0<br>
  outside 'p' 1<br>
  outside 'a' 2<br>
  outside 'n' 3<br>
  inside '$' 0<br>
  outside 't' 1<br>
  outside 'e' 2<br>
  outside 's' 3<br>
  outside 't' 4<br>
  inside '$' 0<br>
  outside ' ' 1 //* <br></p>
  
  <p>I am failing to understand what is happening at //*</p>
  
  <p>Thanks for your help!</p>