为了账号安全,请及时绑定邮箱和手机立即绑定

文件操作问题。fscanf读取为负数?

文件操作问题。fscanf读取为负数?

C++ C
萌新程序猿orz 2019-04-09 21:16:29
struct student *read_file(){ int i=0; struct student *p1=NULL,*head=NULL,*p2=NULL; FILE *pfile; pfile = fopen("student.txt","r"); if(pfile == NULL) { printf("+                     未发现存档                    +\n"); return 0;} while(!feof(pfile)){ p1 = (struct student*)malloc(LEN); fscanf(pfile,"%d%d%d%s%s%s%s%s",&p1->idnum,&p1->cardnum,&p1->date,p1->school,p1->sex, &p1->major,&p1->iden,p1->name);     p1->next=NULL;     if(i==0) head=p1;     else p2->next=p1;     p2=p1;     i++;} fclose(pfile); printf("+                     读档成功                     +\n"); return head;}我的idnum是201820020304 这么长的,可是输入的却是负数,请教大佬
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 1385 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信