一个C结构体写的数据库现在要对它做添加删除修改操作,如何实现?
Write a database to input student information for a class of up to 20 students.
For each student, your program should prompt the User for two pieces of information: an ID number and percentage mark.
You should perform range checking on the entered mark.
Each student should be allocated a grade based upon the following grade definitions:
A >70%
B 60-70
C 50-59
D 40-49
E 30-39
F <30%
The list of Student ID’s, marks and grades should be printed out to the screen.
实现代码如下:
#define NUM 20
struct student
{
char id[10];
int mark;
};
main()
{
struct student stu[NUM];
int i;char grade;
for(i=0;i<NUM;i++)
{
printf("input id:\n");
scanf("%s", stu[i].id);
printf("input mark:\n");
scanf("%d", &stu[i].mark);
}
for(i=0;i<NUM;i++)
{
switch (stu[i].mark/10)
{
case 0:
case 1:
case 2: grade='F';break;
case 3: grade='E';break;
case 4: grade='D';break;
case 5: grade='C';break;
case 6: grade='B';break;
default:
if(stu[i].mark == 70) grade='B';
else
grade='A';
}
printf("%s\t\t%d\t\t%c\n",stu[i].id,stu[i].mark,grade);
}
}
现在要添加对里面数据的添加删除修改的功能,高手指教
insert()
{
}
delete()
{
}
update()
{
}