title: storing dynamic arrays of a struct in text file in c language
body: <p>hello  this is my first year in learning c programming , i spent all day trying to figure this one out and now i have a head ache 
  anyway i just wanna keep this as simple as possible, here is a test code that i want to correct so i can understand how this works 
  what i wanna do is store  a dynamic array of structure variables in a text file, and then reading the data from that text file into a dynamic array.
  this is in c language </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  struct student {
  char nam[3];      // we store to this 
  char testname[3]; // we read to this
  }*science[10];
  int main() {
  int i;
  FILE *ptr=fopen("science_class","a");
  for (i=0;i&lt;3;i++){          //storing the infro from dynamic array into the file
  e[i]=(science*)calloc(3,sizeof(char));
  puts("enter name");
  gets(science[i]-&gt;name);
  fprintf(ptr,"%s",science[i]-&gt;name);  }
  for (i=0;i&lt;3;i++){          // loading the info from the file to a dynamic array
  fscanf(ptr,"%s",&amp;science[i]-&gt;testname)
  printf("name :%s \n",science[i]-&gt;testname) }
  fclose(ptr);
  
  }
  </code></pre>