title: Am I not using fseek() properly?
body: <p>I'm trying to update some info in my binary file, but I'm facing a problem while trying to go backward, to the beginning of the line.</p>
  
  <pre><code>void updateSalary(char* filename)
  {
      int i = 0;
      employee temp;
      char c;
      float increase;
      FILE *fup = fopen(filename, "rb+");
      if (fup == NULL)
      {
          printf("Unable to read the file\n");
          return;
      }
  
      fread(&amp;temp, sizeof(employee), 1, fup);
      while (!feof(fup))
      {
      printf("How big is the increase to %s's salary?\n", temp.name);
      scanf("%f", &amp;increase);
      temp.salary += increase;
      fseek(fup, (i * sizeof(employee)), SEEK_SET);
      fwrite(&amp;temp, sizeof(employee), 1, fup);
      fread(&amp;temp, sizeof(employee), 1, fup);
      i++;
      }
  fclose(fup);
  }
  </code></pre>
  
  <p>The problem is, for instance, if I choose to update 2 employees, for some reason, the while loop doesn't stop at the 2nd employee and the function keep going.. </p>
  
  <p>Thanks in advance.</p>
  
  <p>Edit:
  it seems that the fwrite(); function didn't advance (by position meaning) til the next line, so there is the fixed code:</p>
  
  <pre><code>void updateSalary(char* filename, float threshold)
  {
      int i = 0;
      employee temp;
      char c;
      float increase;
      FILE *fup = fopen(filename, "r+b");
      if (fup == NULL)
      {
          printf("Unable to read the file\n");
          return;
      }
      //fread(&amp;temp, sizeof(employee), 1, fup);
      while (fread(&amp;temp, sizeof(employee), 1, fup))
      {
      printf("How big is the increase to %s's salary?\n", temp.name);
      rewind(stdin);
      scanf("%f", &amp;increase);
      temp.salary += increase;
      fseek(fup, (i * sizeof(employee)), SEEK_SET);
      fwrite(&amp;temp, sizeof(employee), 1, fup);
      **fseek(fup, ((i+1) * sizeof(employee)), SEEK_SET);**
      i++;
      }
  fclose(fup);
  }
  </code></pre>