title: read data from txt file to linked list
body: <p>the code is for creating a shop purchase, stock maintainence system
  <strong>i have a problem in entering data from txt file to linked list with fscanf(fp,............) function;</strong></p>
  
  <p>the code below has the problems written in comments section but breifly, when i run the code in turbo c and enter the data at run time the contents go in the file correctly if i am not reading in older contents. every time i open the program the file is overridden.
  <strong>when i read in the contents with fscanf() junk values start to get added in the file i dont know why</strong>. may be because i am using pointers instead of objects, but i do not know another way.</p>
  
  <p>i know that my program is inefficient but still i want to know what is the problem with the code and how to resolve it
  i have used many variables , some of them might never be used ,pls forgive me.
  problem in the code will be found in the create function:</p>
  
  <pre><code>#include&lt;alloc.h&gt;
  #include&lt;stdio.h&gt;
  #include&lt;conio.h&gt;
  #include&lt;string.h&gt;
  #include&lt;graphics.h&gt;
  #define size 20
  struct shop{
  char name[size];
  int quantity;
  int price;
  struct shop *next;
  }*start;
  typedef struct shop sh;
  
  char u_name[30];
  char u_pass[30];
  
  int i,user,password;
  int k=0,l=0;
  char add_more;
  char c,choice,c1,more;
  
  
  
  
  void create()
  { FILE *fc,*fp;
  
  struct shop *ptr,*temp,*g,*l,*m,*t,*i,*d;
  char ch,v[20];
  int r,z,w,flag=0;
  //the code ***************from here******************
  fc=fopen("storedata.txt","r");
  d=(sh*)malloc (sizeof(sh));
  d-&gt;next=NULL  ;
  i=d;
  m=d;
  
  
  while(fscanf(fc,"%s\t%d\t%d",m-&gt;name,m-&gt;quantity,m-&gt;price)!=EOF)
  {
  d=(sh*)malloc (sizeof(sh));
  m-&gt;next=d;
  m=m-&gt;next;
  
  }
  m-&gt;next=NULL;
  fclose(fc);
  
  t=i;
  
  clrscr();
  printf("NAME\t\t\tQUANTITY\t\t\t\tPRICE(RS)");
  
  do
  {
  printf("\n%s ",t-&gt;name);
  printf("\t\t\t%-20d",t-&gt;quantity);
  printf("\t\t\t%-40d",t-&gt;price);
  t=t-&gt;next;
  }while(t!=NULL);
   getch();
   getch();
  //*************till here********the smaller code part above is the code to read in the file which doesnt work correctly
  start=i;}  // when i remove this line all the values entered in the file are correct but file is overridden every time i run it
  </code></pre>
  
  <p>thanks</p>