学生档案管理问题之二
这个程序可以运行,但是在运行中有些问题!请高手帮帮忙!!!!#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
struct student{
int num ;
char name [10];
char sex[5];
int age;
}student[10];
void student_information();
int search_num();
void student_del();
void student_edit();
void page_title();
void main()
{
menu: page_title("Menu operation");
printf("Please use number keys select Options\n\n");
printf("1 student_information\n2 search_num\n");
printf("3 student_del\n\n4 student_edit\n5 exit\n");
switch (getchar())
{
case '1':
student_information() ;
break;
case '2':
search_num();
break;
case '3':
student_del();
break;
case '4':
student_edit();
break;
case '5':
printf("goodbye !\n");
exit(0);
}
}
void page_title(char *menu_item)
{
clrscr();
printf(">>> Student performance management system <<<\n\n- %s -\n\n",menu_item);
}
void return_confirm(void)
{
printf("\nPress any button to return......\n");
getch();
}
void student_information(void)
{
int n;
page_title("Input students basic information");
for(n=0;n<10;n++)
if(student[n].num==0) break;
printf("num:");
scanf("%d",&student[n].num);
printf("name:");
scanf("%s",&student[n].name);
printf("age:");
scanf("%d",&student[n].age);
return_confirm();
}
int search_num()
{
int n,i;
printf("plese input num:");
scanf("%d",&i);
for(n=0;n<10;n++)
{
if(student[n].num==i&&student[n].num!=0)
{
printf("num:%d\n",student[n].num);
printf("name:%s\n",student[n].name);
printf("age:%d\n",student[n].age);
return n;
}
}
printf("\ninput error or wrong number.\n");
return -1;
}
void student_del()
{
int n;
page_title("delete students basic information");
if((n=search_num())!=-1)
{ student[n].num=0;
printf("\n!The students have been deleted.\n");
}
return_confirm();
}
void student_edit()
{
int n;
page_title("editor students basic information");
if((n=search_num())!=-1)
{
printf("\nRe-enter new information:\nnum:");
scanf("%d",&student[n].num);
printf("name:");
scanf("%s",&student[n].name);
printf("age:");
scanf("%d",&student[n].age);
}
return_confirm();
}
在图2的地方不能返回了,本来设计的思想是返回继续的!