int main()
{
errno_t err;
FILE *fp;
int a, b, q;
if ((err = fopen_s(&fp, "ben.txt", "rb+")) == NULL)
{
printf("cannot open\n");
exit(0);
}
fscanf_s(fp, "%d", &a);
printf("请输入密码:\n");
k: scanf_s("%d", &b);
if (a != b)
{
printf("密码错误!\n");
printf("请重新输入密码:\n");
goto k;
}
else
printf("\n\t\t\t欢迎进入学生成绩管理系统\n\n\n");
printf("1.学生成绩系统\n");
printf("2.学生个人信息系统\n");
printf("请输入选项:");
scanf_s("%d", &q);
switch (q)
{
case 1:printf("\t\t\t\t \n\n\n\n");
printf("\t\t\t \n\n");
printf("\t\t\t 按任意键进入…………\n");
getchar();
CreateHeadLink();
ReadInfoFormFile();
Menu();
break;
case 2:menu1();
}
}
void ReadInfoFormFile(void)
{
errno_t err;
FILE *fp;
STUDENT *p;
err = fopen_s(&fp, "student.txt", "r");
if (!fp)
{
printf("\n");
return;
}
p = MallocNode();
while (fscanf_s(fp, "%s%s%s%f%f%f", p->Number, p->Name, p->className, &(p->mark1), &(p->mark2), &(p->mark3)) > 0)
{
InsertOneNode(p);
p = MallocNode();
}
fclose(fp);
}
/*显示菜单*/
void Menu()
{
STUDENT *p;
printf("\t***************************************************************\n\n");
printf("\t0: 修改密码\n");
printf("\t1: 显示所有学生的信息\n");
printf("\t2: 按姓名查询\n");
printf("\t3: 增加学生\n");
printf("\t4: 根据学生学号删除该学生\n");
}
|