title: understanding usage of fseek
body: <pre><code>#include&lt;stdio.h&gt;
  int main(int argc, char **argv){
      FILE *fp = NULL;
      fp = fopen("D://test.txt","wb");
      if(fp == NULL){
          printf("Error opening file\n");
      }
  
      typedef struct{
          int a;
          char b;
      }A;
  
      A x = {12, 'a'}, y = {13, 'b'},z;
      fwrite(&amp;x, sizeof(A), 1, fp);
      fwrite(&amp;y, sizeof(A), 1, fp);
  
      fseek(fp, sizeof(A), SEEK_SET);
  
      fread(&amp;z, sizeof(A), 1, fp);
      printf("%d  %c\n", z.a, z.b);
      return 0;
  }
  </code></pre>
  
  <p>I intend to write 2 structures to a file. Then I need to position the file pointer to the beginning of the 2nd structure in the file and then perform fread from there to read the 2nd structure into z. The values are not read into z properly. I am not getting where the problem is.</p>