title: Program demonstrate file IO operations
body: <p>Im trying to get started with io operations with c programming. i'm often facing the error 
  " segmentation fault core dumped ". is there any one to clearly explain why im getting this error.
  and how to avoid this silly error angain?</p>
  
  <p>thanks in advance..</p>
  
  <pre><code>struct Subscriber { char *name; char msisdn[10+1]; };
  
  int main() {
  
    FILE * ostream;
    ostream = fopen("UsersData.dat","w");
    struct Subscriber record;
    do {
      printf(" Enter subscriber record[name&lt;Ent&gt;msisdn&lt;Ent&gt;] :");
      scanf("%s",&amp;record.name);
      scanf("%s",&amp;record.msisdn);
      printf("Record [ %s | %s ] \n", record.name, record.msisdn);
      fwrite(&amp;record, sizeof(record), 1, ostream);
      printf(" Do want to Insert new record? [y/n] : ");
      fflush(stdin);
    } while ('y' == getc(stdin));
    fclose(ostream);
    printf(" file closed ");
    return 0;
  }
  </code></pre>