求指教文件指针问题
struct Dem *F_read(void){
FILE *fp;
int i=500;
struct Dem *q,*head,*p=NULL;
head=(struct Dem*)malloc(sizeof(struct Dem));
printf("读取文件...\n");
if((fp=fopen("d:\\GTBL.dat","rt+"))!=NULL)//&&(fp2=fopen("d:\\SortGTNL1.dat","wb+"))!=NULL)
{
extern int n;
printf("读取中...\n");
while(i--)//(ch=getc(fp))!=EOF,,i--;!feof(fp)
{
n=n+1;
q=(struct Dem*)malloc(sizeof(struct Dem));
fread(&q->data,sizeof(UINT2),1,fp);
fread(&q->R_num,sizeof(UINT4),1,fp);
fread(&q->R_size,sizeof(UINT2),1,fp);
fread(&q->R_iform,sizeof(UINT4),1,fp);
if((MC_GET_SHORT(&q->data)-12)==0)
q->R_name[20]='\0';
else
fread(q->R_name,(MC_GET_SHORT(&q->data)-12),1,fp);
q->r_iform.Fh=(UINT1)(MC_GET_LONG(&q->R_iform)&0x0F);
q->r_iform.Lk=((UINT1)(MC_GET_LONG(&q->R_iform)&0x70))>>4;
q->r_iform.flag=((UINT1)(MC_GET_LONG(&q->R_iform)&0x80))>>4;
// q->r_iform.Em=(UINT1)(MC_GET_LONG(&q->R_iform)>>8);
if(n==1) head->next=q;
else p->next=q;
p=q;
if(i<=72)
{
int m;
m=ferror(fp);
printf("%d,%d\n",m,*fp);
printf("%d %x %d %ld %s %d %d %d\n",MC_GET_SHORT(&q->data),MC_GET_LONG(&q->R_num),MC_GET_SHORT(&q->R_size),MC_GET_LONG(&q->R_iform),q->R_name,q->r_iform.Fh,q->r_iform.Lk,q->r_iform.flag);
// printf("%d %d %d\n",q->r_iform.Fh,q->r_iform.Lk,q->r_iform.flag);
}
}
p->next=NULL;
fclose(fp);
printf("文件读取成功!\n");
}
return(head);
}
当读到432个数据的时候fp就不动了。。。求指教 困扰我好几天了