结构体stud的每个元素每个值初始化为0,输出写入文件前,加个判断,if(stud[j].clas==0)break;
用for循环
for (int i = 0; i < n; i++) fprintf(fp, ..., stud[i]...);