没有合适的资源?快使用搜索试试~ 我知道了~
编制一个学生籍贯信息管理系统,每个学生信息包括:学号、姓名、籍贯。具体功能: (1)创建信息链表并以磁盘文件保存; (2)读取磁盘文件并显示输出所有学生的籍贯信息; (3)按学号或姓名查询其籍贯; (4)按籍贯查询并输出该籍贯的所有学生; (5)能添加、删除和修改学生的籍贯信息;
资源推荐
资源详情
资源评论
#include <stdio.h>
#include <malloc.h>
#define LEN sizeof(struct student)
#define NULL 0
struct student
{long num;
char name[20];
char jg[20];
struct student *next;
};
int n=0;
void save(struct student *head)
{ FILE *fp;
char filename[20];
struct student *p1;
printf("Please input the filename\n");
scanf("%s",filename);
if((fp=fopen(filename,"w"))==NULL)
{printf("can't open file\n");
return;
}
for(p1=head;p1!=NULL;p1=p1->next)
{fprintf(fp,"%ld",p1->num);
fputc('\t',fp);
fprintf(fp,"%s",p1->name);
fputc('\t',fp);
fputc('\t',fp);
#include <malloc.h>
#define LEN sizeof(struct student)
#define NULL 0
struct student
{long num;
char name[20];
char jg[20];
struct student *next;
};
int n=0;
void save(struct student *head)
{ FILE *fp;
char filename[20];
struct student *p1;
printf("Please input the filename\n");
scanf("%s",filename);
if((fp=fopen(filename,"w"))==NULL)
{printf("can't open file\n");
return;
}
for(p1=head;p1!=NULL;p1=p1->next)
{fprintf(fp,"%ld",p1->num);
fputc('\t',fp);
fprintf(fp,"%s",p1->name);
fputc('\t',fp);
fputc('\t',fp);
fprintf(fp,"%s",p1->jg);
fputc('\n',fp);
}
free(p1);
fclose(fp);
}
void print(struct student *head)
{ struct student*p;
printf("\nNow,these information is:\n");
p=head;
if(head!=NULL)
do
{printf("%ld\t%s\t\t%s\n",p->num,p->name,p->jg);
p=p->next;
}while(p!=NULL);
}
struct student *creat()
{ struct student *head,*p1,*p2;
char ch;
p1=p2=(struct student *)malloc(LEN);
printf("\n Welcome to student jiguan system!\n");
printf("Please input one's num,name and jiguan\n");
printf("\"0 0 0\":exit\n");
scanf("%ld%s%s",&p1->num,p1->name,p1->jg);
head=NULL;
while(p1->num!=0)
{n=n+1;
if(n==1)head=p1;
fputc('\n',fp);
}
free(p1);
fclose(fp);
}
void print(struct student *head)
{ struct student*p;
printf("\nNow,these information is:\n");
p=head;
if(head!=NULL)
do
{printf("%ld\t%s\t\t%s\n",p->num,p->name,p->jg);
p=p->next;
}while(p!=NULL);
}
struct student *creat()
{ struct student *head,*p1,*p2;
char ch;
p1=p2=(struct student *)malloc(LEN);
printf("\n Welcome to student jiguan system!\n");
printf("Please input one's num,name and jiguan\n");
printf("\"0 0 0\":exit\n");
scanf("%ld%s%s",&p1->num,p1->name,p1->jg);
head=NULL;
while(p1->num!=0)
{n=n+1;
if(n==1)head=p1;
剩余12页未读,继续阅读
资源评论
sy7677739
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功