哪个可以帮忙看下!这是个纠结的问题
为什么我最后输出的“学号”会成数字4356560????????#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define M 100
struct information{
char name[20];
char grade[4];
int num;
}em[100];
void menu();
int input();
void save();
void display();
void menu()
{
puts("1.input inform");
puts("2.save the inform");
puts("3.Display inform");
puts("4.Exit");
printf("\n");
}
void main()
{
int n,flag,b;
char a;
menu();
do
{
printf("Enter your Choice(1--5):\n");
scanf("%d",&n);
if(n>=1&&n<=4)
{
flag=1;
break;
}
else
{
flag=0;
printf("your Choice is false,Enter your Choice!");
}}
while(flag==0);
while(flag==1)
{
switch(n)
{
case 1:b=input();break;
case 2:save(b);break;
case 3:display(b);break;
case 4:exit(0);break;
}
getchar();
printf("请输入y继续\n");
scanf("%c",&a);
if(a=='y')
{flag=1;
system("cls");
menu();
printf("Enter your Next Choice(1--3):\n");
scanf("%d",&n);
printf("\n");
}
else
exit(0);
}
}
int input()
{
int i,m;
printf("Please Enter the number of student(1--100):\n");
scanf("%d",&m);
for(i=0;i<m;i++)
{ printf("\t姓名:");scanf("%s",&em[i].name);getchar();
printf("\t成绩等级:");scanf("%s",&em[i].grade);getchar();
printf("\t学号:");scanf("%d",&em[i].num);getchar();}
printf("\n 创建完毕!\n");
return m;
}
void save(int m)
{
int i;
int a;
FILE *fp;
if((fp=fopen("file1.dat","w"))==NULL)
{
printf("cannot open file1\n");
exit(0);
}
for(i=0;i<m;i++)
fprintf(fp,"%s %s %d",em[i].name,em[i].grade,&a);
em[i].num=a;
printf("存储完毕\n");
fclose(fp);}
void load(int m)
{
FILE*fp;
int i=0;
int a;
if((fp=fopen("file1.dat","r"))==NULL)
{
printf("can't open file1\n");
exit(0);
}
else
{
do
{
fscanf(fp,"%s%s%d",&em[i].name,&em[i].grade,&a);
i++;
}
while(i<m);
}
fclose(fp);
}
void display(int m)
{
int i,a=0,b=0,c=0,d=0,e=0;
printf("---------------同学记录-----------------\n");
printf("%s%15s%15d\n","姓名","等级","学号");
for(i=0;i<m;i++)
printf("\n%s\t%9s\t%10d\t\n",em[i].name,em[i].grade,em[i].num);
{printf("\n---------各等级成绩的人数------------\n");
if(em[i].grade[4]=='A')a=a+1;
if(em[i].grade[4]=='B')b=b+1;
if(em[i].grade[4]=='C')c=c+1;
if(em[i].grade[4]=='D')d=d+1;
if(em[i].grade[4]=='E')e=e+1;}
{printf("A:%d B:%d C:%d D:%d E:%d",a,b,c,d,e);}
getchar();
}