有一道C语言的问题,本人实在无能为力,望高手赐教

来源:百度知道 编辑:UC知道 时间:2024/06/14 14:20:49
4.1系统概要
该系统实现了对学生通讯信息的存储和管理。学生信息至少包括姓名、手机、家庭电话、宿舍号4项信息。系统可以对学生信息进行查询、添加、删除和备份。
4.2基本功能要求
(1)、能按期中一种信息(姓名、手机、家庭电话、宿舍号)对记录进行查询
(2)、能插入一个记录,按照姓名对记录删除
(3)、实现学生信息的输出、备份(输出到一个新文件)。
(4)、能够按照姓名或宿舍号排序(两个都要实现)。
(5)、要求必须用链表(如,单向链表)实现处理过程。
(6)、事先编辑示例的数据文件raw.txt。然后从文件直接读取数据。
(7)、使用菜单界面,菜单的最后一项存盘退出,输出到addressbook.txt中。
4.4系统数据结构和函数的设计
1)数据结构:
结构体成员包括:name, cellphone, homephone, dormno,自己可以增加其它结构体成员。
struct add
{ char name[20];
char cellphone[12];
char homephone[13];
char dormno[6];
};
2)函数:
以下功能应该用独立的函数实现:读入数据(即创建链表);插入节点;删除节点;排序;打印(输出到屏幕);输出到文件;
附录:原始数据示例 raw.txt
LiLin 13312345678 024512342678 2-289
ZhangFan 13412345676 034712345608 3-456
WangSi 13312845378 036512045678 3-456
WuLi 13012345078 034532345318 4-702
ShiQing 13912325673 01012375678 9-139

#include "stdio.h"
#include "stdlib.h"
#include "string.h"
typedef struct stud
{
char name[20];
char cellphone[12];
char homephone[13];
char dormno[6];
struct stud *next;
};
int menu()
{
int n;
char c;
printf("1.find 2.add student 3.delete student 4.compositor name\n5.compositor dormno6.save file 7.list 8.Save As\n9.quit\n");
printf("Input Option:");
scanf("%d",&n);
if(n<0&&n>10) return 0;
while ( (c = getchar()) != '\n' && c != EOF ) ;
return n;
}
int show(stud *p)
{
if(!p)return 0;
printf("name\t cellphone\t homephone\t dormno\n");
printf("%s\t%s\t%s\t%s\n",p->name,p->cellphone,p->homephone,p->dormno);
ret