The problem of writing data to linked list in c language file

Daniel, help me to find out why my code can only read one set of data, and when multiple sets of data are written, the previous set will be overwritten
int bookread(){
 ptcs p=head;
 int i,m,j=0;
 ptcs tem;     
 FILE* fp;
 if((fp=fopen("D:\\bookdata.txt","rb"))== NULL){
  printf("Failed to open file\n");
  return -1;
 }
 fseek(fp,0,SEEK_END); 
 i=ftell(fp); //Get the text size
 fseek(fp,0,SEEK_SET); //Move the text pointer to the beginning of the text
 m=(i/(sizeof(book))); //Get the number of contacts in the text Correct
 book b;
 while(m>0){
  fread(&b,sizeof(book) ,1,fp);
  tem=(ptcs)malloc(sizeof(*tem));
  tem->next=p;
  memset(tem,0,sizeof(*tem));
  memcpy(tem,&b,sizeof(book) );
  p->next=tem;
  j++;
  m--;
 }
 fclose(fp);
 printf("Read information completed!\n");
 return 0; 
}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326586923&siteId=291194637