title: Updating value of fields of structure from a file in C?
body: <p><strong>This is my structure:</strong></p>
  <pre><code>struct votes{
  int voter_num;
  int total_votes:
  }
  </code></pre>
  <p>i try to update file this way but didn't out to be worked:</p>
  <pre><code>FILE *vfp;
  vfp=fopen(&quot;hello.dat&quot;,&quot;rb+&quot;);
  struct votes display;
  display={100,2};
  fwrite(&amp;display,sizeof(votes),1,vfp);
  fclose(vfp);
  
  </code></pre>
  <p>firstly it gets updated as i get total_votes as 2 when i run code next time but again if i change <code>display={100,2}</code> to something like this<code>display={100,4}</code> i got total_votes 2 insted of 4.this is the issue i m facing</p>