title: Having problems with fseek() in C
body: <p>So, I have this function on my program that is supposed to save a "car_str" structure into the desired place on a file specified as a parameter. But when I run it, it keeps overwriting the first slot again and again, as if fseek didn't point to the specified place on the file. Is there any problem with my code? I think it may be related with the multiplication, since without it the program does well, but I cannot point to the place I want.</p>
  
  <pre><code>void save(int car_nbr)
  {
      FILE *f;
  
      f = fopen("memory.txt","wb");
      if (!f)
      {
          printf ("error");
      }
      else
      {
          car_nbr--;
          fseek(f, sizeof(struct car_str)*car_nbr, SEEK_SET);
          fwrite(&amp;car,sizeof(struct car_str),1,f);
          rewind(f);
          fclose(f);
          printf("\nsaved");
      }
  }
  </code></pre>