c语言电话系统编程,c语言电话本编程课程设计完整版.doc

c语言电话本编程课程设计完整版

计算机程序设计(c语言)

课程设计报告

题目:通讯录

学院:

专业:

班级:

姓名:

指导教师:

答辩日期: 年 月 日

一、 设计背景介绍 二、 任务概述部分三、 设计流程

四、 #include

struct person

{

char name[8];

char QQ[15];

char tel[15];

char addr[50];

};

char filename[20];

void creat();

void search();

void append();

void modify();

void delete();

FILE *fp;

main()

{

int m;

creat();

while(1)

{

printf("\n\append,please enter1");

printf("\nsearch, please enter,2");

printf("\nmodify, please enter3");

printf("\ndelete, please enter4");

printf("\nexit, please enter0\n");

scanf("%d",&m);

if(m>=0&&m<=4)

{

switch(m)

{

case 1:append();

break;

case 2:search();

break;

case 3:modify();

break;

case 4:delete();

break;

case 0:exit();

}

printf("\n\nend edited please select");

}

else

printf("\n\nerror please try again");

}

}

void creat()

{

struct person one;

printf("\nplease input a filename:");

scanf("%s",filename);

if((fp=fopen(filename,"w"))==NULL)

{

printf("\ncan not establish a filename");

exit();

}

fclose(fp);

}

void append()

{

struct person one;

if((fp=fopen(filename,"a"))==NULL)

{

printf("\ncan not open the file");

exit();

}

printf("\nplease input the name:\n");

scanf("%s",one.name);

printf("\nplease input the QQ:\n");

scanf("%s",one.QQ);

printf("please input the tel:\n");

scanf("%s",one.tel);

printf("\nplease input the address:\n");

scanf("%s",one.addr);

fprintf(fp, "%-10s\n",one.name);

fprintf(fp, "%-20s\n",one.QQ);

fprintf(fp, "%-20s\n",one.tel);

fprintf(fp, "%-50s\n",one.addr);

fclose(fp);

}

void search()

{

int k=0;

char namekey[8];

struct person one;

printf("\nplease input a name:");

scanf("%s",namekey);

if((fp=fopen(filename,"rb"))==NULL)

{

printf("\ncan not open the file");

exit();

}

while(!feof(fp))

{

fscanf(fp,"%s\n",one.name);

fscanf(fp,"%s

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值