关于fgets函数

L_chxu L_chxu 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

void read_data(void)
{
FILE *fp;
int i,j;

char str[1000];
fp = fopen("th.txt","r");
if (fp == NULL)
{
printf("Can't open the file!\n");
return ;
}

fgets(str,1000,fp);//此句中str从fp中读取数据后,下面语句中并没有用到str,
// str的作用的什么?此句为何不能少?

for (i=0; i<N; i++)
{
fscanf(fp,"%s\t%d\t",stud[i].name,&stud[i].num);
for (j=0; j<M; j++)
{
fscanf(fp,"%d\t",&stud[i].score[j]);
}
}
printf("姓名 学号 英语 C语言 线性代数 离散数学 高等数学 密码学\n");
for (i=0; i<N; i++)
{
printf("%s\t%d\t",stud[i].name,stud[i].num);
for (j=0; j<M; j++)
{
printf("%d\t",stud[i].score[j]);
}
printf("\n");
}
}

...全文

相关推荐

评论 15
收藏 已收藏
分享
返回顶部
L_chxu
C语言 70,040 成员 243,237 内容