为什么我提取文件只能提取最后一行,我想将文件每行分别提取并显示出来

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

struct student//学生信息
{
	int num=0;
	char name[20] = {0};
	int age=0;
	char sex[10]= { 0 };
	int year=0;
	int month=0;
	int day=0;
	char location[100]= { 0 };//可能不够
	int phone=0;
	char Email[100]= { 0 };

};

int main()     //百度   //查行数 计数学生总数
{
	
	struct student s;
	int n;//循环
	FILE *pf = fopen("E:\\work\\保存\\c语言程序设计1\\程序\\录入功能\\luru.txt", "r");
	char buf[1000];//??????缓冲区???
	int lineCnt = 0;
	if (pf==NULL)
		return  -1;
	while (fgets(buf, 1000, pf))
		lineCnt++;
	printf("学号\t姓名\t年龄\t性别\t出生日期\t地址\t电话\t邮件\n");

	for (n = 0;n < lineCnt;n++)
	{
		fgets(buf, 1000, pf);
		sscanf(buf, "%d %s %d %s %d %d %d %s %d %s",&s.num, s.name, &s.age, s.sex, &s.year, &s.month, &s.day, s.location, &s.phone,s.Email);           //可能是这个地方有问题
		printf("%d\t%s\t%d\t%s\t%d %d %d\t%s\t%d\t%s\n", s.num, s.name, s.age, s.sex, s.year, s.month, s.day, s.location, s.phone, s.Email);
	}


	printf("\n当前录入学生总数为%d\n", lineCnt);
	fclose(pf);
	return 0;
}

 

这是我想读取的文件

这是最后结果

 不知道问题出在哪里

while循环的时候已经把整个文件流读完了。

for循环中的fgets没有读到任何内容。当fgets没有读到任何内容,第一个参数的值保持不变。