#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#define M 50
typedef struct
{
char name[20];
char units[30];
char tele[10];
}ADDRESS;
/*函数原型*/
int enter(ADDRESS t[]);/*输入记录*/
void list(ADDRESS t[],int n);/*显示记录*/]
void search(ADDRESS t[],int n);/*按姓名查找显示*/
int delete(ADDRESS t[],int n);/*删除记录*/
int add(ADDRESS t[],int n);/*插入记录*/
void save(ADDRESS t[],int n);/*记录保存为文件*/
int load(ADDRESS t[]);/*从文件读取记录*/
void display(ADDRESS t[]);/*按序号查找显示记录*/
void sort(ADDRESS t[],int n);/*按名字排序*/
void qseek(ADDRESS t[],int n);/*快速查找记录*/
void copy();/*文件复制*/
void print(ADDRESS t[],temp);/*显示单条记录*/
int find(ADDRESS t[],int n,char*s);/*查找函数*/
int menu_select();/*主菜单函数*/
/*主函数开始*/
main()
{
int t;
ADDRESS adr[M];/*定义结构体数组*/
int length;/*保存记录长度*/
clrscr();/*清屏*/
for(;;)
{
switch(menu_select())
{
case 0:length=enter(adr);break;
case 1:list(adr,length);break;
case 2:search(adr,length);break;
case 3:length=delete(adr,length);break;
case 4:length=add(adr,length);break;
case 5:save(adr,length);break;
case 6:length=load(adr);break;
case 7:display(adr);break;
case 8:sort(adr,length);break;
case 9:qseek(adr,length);break;
case 10:copy();break;
case 11:exit(0);
}
}
}
menu_select()
{
char s[80];
int c;
gotoxy(1,25);
printf("press\n");
getch();
clrscr();
gotoxy(1,1);
printf("***********MENU************\n");
printf("0.Enter record\n");
printf("1.List the file\n);
printf("2.Search record on name\n");
printf("3.Delete record\n");
printf("4.add record\n");
printf("5.Save file\n");
printf("6.Load file\n");
printf("7.display record on order\n");
printf("8.sort to mark new file\n");
printf("9.Quick seek record\n");
printf("10.Copy file to new file\n");
printf("11.Quit\n");
printf("****************************\n");
do{
printf("Enter choice(0~11):");
scanf("%d",s);
}while(c<0||c>11);
return c;
}
/*输入记录*/
int enter(ADDRESS t[])
{
int i,n;
char*s;
clrscr();
printf("input num\n");
scanf("%d",&n);
printf("input record\n");
printf("name unit telephone\n");
for(i=0;i<n;i++)
{
scanf("%s,%s,%s",t[i].name,t[i].units,t[i].tele);
}
return n;
}
请问一下删除和添加处应怎么写~~~~~给我一些类似的程序,我参考一下~!谢谢各位!