找回密码
 注册
搜索
热搜: 回贴
  • 前程无忧官网首页 有什么好的平台可以
  • 最新的销售平台 互联网营销的平台有哪
  • 制作网页的基本流程 网页制作和网页设
  • 【帝国CMS】输出带序号的列表(数字排
  • 网站建设公司 三一,中联,极东泵车的
  • 织梦 建站 织梦网站模版后台怎么更改
  • 云服务官网 哪些网站有免费的简历模板
  • 如何建网站要什么条件 建网站要用什么
  • 吉林市移动公司电话 吉林省退休人员网
  • 设计类毕业论文 网站设计与实现毕业论
查看: 205|回复: 8

【求教】通讯录管理系统(只要修改一个子函数)

[复制链接]
发表于 2009-11-5 00:26:19 | 显示全部楼层 |阅读模式 IP:江苏扬州
我们课程设计要做一个通讯录管理系统,我们才上大一,现在一点头绪都没有,想请各位高手指点一二。
要求:
设计技术参数:
1用指针数组来保存人的信息,指针数组里每一个单元保存一个人的地址,每个人的信息是一个结构体,包括编号、姓名、地址。(人数最多50人,即指针数组的大小是确定的)
2采用多文件程序结构,把不同功能的函数写在不同的文件中,在项目文件的管理下统一编译后生成EXE文件。
3对于增加的个人记录采用动态生成分配空间后,动态生成节点的方法。
设计要求:
设计完成一个通讯录管理系统,能够利用这个系统方便地管理同学的个人信息。必须完成以下功能:增加、删除、调入、保存、显示、退出功能。要求多人配合完成,相互协调好头文件,外部变量,数组类型结构等。要求有三人合作完成。重点需要明确的是通讯录人数的管理。

谢谢各位啦
发表于 2009-11-5 00:26:22 | 显示全部楼层 IP:江苏扬州
哇~仅仅是思路耶~可以指点一二吗?我真的不知道怎么作啊
回复

使用道具 举报

发表于 2009-11-5 00:26:23 | 显示全部楼层 IP:江苏扬州
如果你学过vector的话,那么你仔细看看vector的各个函数那就有思路了..
实在没有学过那就用一个单向的链表也可以解决...
回复

使用道具 举报

发表于 2009-11-5 00:26:25 | 显示全部楼层 IP:江苏扬州
我没有学过耶~
呵呵,找到了一个C的程序,现在想问下,文件的读写操作C和C++的区别在哪里?要怎么把它们转过来呢?
程序:void load()/*加载*/
{
FILE *fp;
int i=0;
r_cnt=0;
if((fp=fopen("FF.txt","rb"))!=NULL)
{
while(!feof(fp))
{
fread(&frd[i],sizeof(struct friends),1,fp);
r_cnt++;
printf("%s %s %s %s\n",frd[i].name,frd[i].tel,frd[i].e_mail,frd[i].address);
i++;
}
}
else
puts("open error!");
fclose(fp);
}
回复

使用道具 举报

发表于 2009-11-5 00:26:26 | 显示全部楼层 IP:江苏扬州
在C++中传统的C语言的文件操作也是可以的;
如fprintf(fp,"%d",num); /*将num写入fp中*/
只要包含了"stdio.h";

在C++中是用流来读写文件的;
如:ifstream in_fp("file_name","open_type");
然后用 fp>>x;
就可以把x读入文件了;
同理:ofstream out_fp("file_name","open_type");
然后用 fp<<x;
就可以把Z值读到x了;
回复

使用道具 举报

发表于 2009-11-5 00:26:28 | 显示全部楼层 IP:江苏扬州
好象反了;
ifstream in_fp("file_name","open_type");
fp>>x;
就可以把值读到x了;
ofstream out_fp("file_name","open_type");
然后用 fp<<x;
就可以把值x写到文件;
回复

使用道具 举报

发表于 2009-11-5 00:26:31 | 显示全部楼层 IP:江苏扬州
这是我同学找到的程序,可以运行,但是删除函数某个地方出错了,可以帮我看看修改下吗?




#include <stdio.h>
#define N 50
struct txl
{
char name[20];
char phone[15];
char addrss[30];
}lxren[N];
FILE *fp;
input();
modify();
add();
del();
display();
search();
main()
{
char t;
while(1)
{
printf(" ************ WELCOME TO USE THIS PROGRAM **********\n");
printf(" * [0]---Input information *\n");
printf(" * [1]---Modify infomation *\n");
printf(" * [2]---Add infomation *\n");
printf(" * [3]---Delete infomation *\n");
printf(" * [4]---Search infomation *\n");
printf(" * [5]---Display all infomation *\n");
printf(" * [6]---Exit *\n");
printf(" *******************************************************\n");
printf(" Please choose(0~6):\n");
flushall();
scanf("%c",&t);
switch(t)
{
case '0':input();break;
case '1':modify();break;
case '2':add();break;
case '3':del();break;
case '4':search();break;
case '5':display();break;
case '6':exit(1);
default :printf("Your prest error!!!Please select again....\n");
getch();break;
}
}
}
input()
{
int i=0;
FILE *fp;
char flag='Y';
if((fp=fopen("list.txt","at+"))==NULL)
{
printf("Can't open this file!!!");
getch();
exit(1);
}
while(flag=='Y'||flag=='y')
{
printf("Name:\n");
scanf("%s",lxren[i].name);
printf("Phone:\n");
scanf("%s",lxren[i].phone);
printf("Addrss:\n");
scanf("%s",lxren[i].addrss);
if(fwrite(&lxren[i],sizeof(struct txl),1,fp)!=1)
{
printf("Error!!!");
getch();
exit(1);
}
else printf("Success!!!\n");
flushall();
printf("Continue Input?(Y/N):");
scanf("%c",&flag);
i++;
}
fclose(fp);
}
modify()
{
struct txl modify_lxren[N],m;
int i,j,t;
char modify_name[10];
if((fp=fopen("list.txt","rt"))==NULL)
{
printf("Open file error!!!\n");
getch();
exit(0);
}
for(i=0;i<N;i++)
{
j=fgetc(fp);
if(j==EOF&&i==0) {printf("This file haven no record!!!\n");getch();return;}
if(j==EOF&&i!=0) break;
fseek(fp,i*sizeof(struct txl),0);
fread(&modify_lxren[i],sizeof(struct txl),1,fp);
}
fclose(fp);
printf("Input the name you will modify:\n");
scanf("%s",modify_name);
for(t=0;t<i;t++)
{
if(strcmp(modify_name,modify_lxren[t].name)==0)
{
printf("Input the info you will modify:\n");
printf("modify name:\n");
scanf("%s",modify_lxren[t].name);
printf("modify phone:\n");
scanf("%s",modify_lxren[t].phone);
printf("modify addrss:\n");
scanf("%s",modify_lxren[t].addrss);
break;
}
}
if((fp=fopen("list.txt","wt"))==NULL)
{
printf("Open file error!!!\n");
getch();
exit(0);
}
for(t=0;t<i;t++)
fwrite(&modify_lxren[t],sizeof(struct txl),1,fp);
printf("Modify Success!!!\n");
getch();
fclose(fp);
}
add()
{
struct txl add_lxren;
if((fp=fopen("list.txt","at+"))==NULL)
{
printf("Open file error!!!\n");
getch();
exit(0);
}
printf("Input the info you will add:\n");
printf("Add name:\n");
scanf("%s",add_lxren.name);
printf("Add phone:\n");
scanf("%s",add_lxren.phone);
printf("Add addrss:\n");
scanf("%s",add_lxren.addrss);
fwrite(&add_lxren,sizeof(struct txl),1,fp);
fclose(fp);
printf("Add Success!!!");
getch();
}
del()
{
struct txl del_lxren[N];
char delete_name[10];
int i,j,t;
if((fp=fopen("list.txt","rt"))==NULL)
{
printf("Open file error!!!\n");
getch();
exit(0);
}
for(i=0;i<N;i++)
{
j=fgetc(fp);
if(j==EOF&&i==0) {printf("This file haven no record!!!\n");getch();return;}
if(j==EOF&&i!=0) break;
fseek(fp,i*sizeof(struct txl),0);
fread(&del_lxren[i],sizeof(struct txl),1,fp);
}
fclose(fp);
printf("Input the name you will delete:\n");
scanf("%s",delete_name);
for(t=0;t<i;t++)
if(strcmp(delete_name,del_lxren[t].name)==0)
{
printf("The info will be delete as follow:\n");
printf("%s %s %s\n",del_lxren[t].name,del_lxren[t].phone,del_lxren[t].addrss);
getch();
break;
}
for(j=t;j<t-1;j++)
del_lxren[j]=del_lxren[j+1];
if((fp=fopen("list.txt","w"))==NULL)
{
printf("Open file error!!!\n");
getch();
exit(0);
}
for(j=0;j<i;j++)
fwrite(&del_lxren[j],sizeof(struct txl),1,fp);
printf("\nDelete Success!!!\n");
fclose(fp);
getch();
}
search()
{
int i,j,t;
char search_name[10];
struct txl search_lxren[N];
if((fp=fopen("list.txt","rt"))==NULL)
{
printf("Open file error!!!\n");
getch();
exit(0);
}
for(i=0;i<N;i++)
{
j=fgetc(fp);
if(j==EOF&&i==0) {printf("This file haven no record!!!\n");getch();return;}
if(j==EOF&&i!=0) break;
fseek(fp,i*sizeof(struct txl),0);
fread(&search_lxren[i],sizeof(struct txl),1,fp);
}
if(i==N) {printf("No any records!!!"); getch(); exit(0);}
fclose(fp);
printf("Input the name you will search:\n");
scanf("%s",search_name);
for(t=0;t<=i;t++)
if(strcmp(search_name,search_lxren[t].name)==0)
{
printf("The info you will search as follow:\n");
printf("%s %s %s\n",search_lxren[t].name,search_lxren[t].phone,search_lxren[t].addrss);
getch();
return;
}
}
display()
{ int i;
struct txl dis_lxren[N];
int j;
if((fp=fopen("list.txt","at+"))==NULL)
{
printf("Open file error!!!");
getch();
exit(0);
}
printf("Name Phone Addrss\n");
printf("--------------------------------------------------------\n");
for(i=0;i<N;i++)
{
j=fgetc(fp);
if(j==EOF&&i==0) {printf("This file haven no record!!!\n");getch();return;}
if(j==EOF&&i!=0) break;
fseek(fp,i*sizeof(struct txl),0);
fread(&dis_lxren[i],sizeof(struct txl),1,fp);
printf("%s %s %s \n",dis_lxren[i].name,dis_lxren[i].phone,dis_lxren[i].addrss);
flushall();
}
fclose(fp);
}
回复

使用道具 举报

发表于 2009-11-5 00:26:33 | 显示全部楼层 IP:江苏扬州
没错把。
你在那个环境下运行
这样也能通过?
回复

使用道具 举报

发表于 2009-11-5 00:26:36 | 显示全部楼层 IP:江苏扬州
不行啊~都能显示,但是不能执行删除程序。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-10-1 07:28 , Processed in 0.397574 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表