当前位置:首页 > 资格考试 > 正文

求大神用c语言编写小型通讯录,用VC或DC编译

用C语言如何做通讯录?

因为不知道你要实现什么功能,给个程序仅供参考 编译环境:vc++6.0 #include #include using namespace std; typedef struct { char name[25];//姓名 char number[50];//电话号码 int a;//序号 char cls;//分类 char mail[50];//邮箱 }BOOK; typedef struct node { BOOK data; struct node *next; }Node,*Link; void Menu() { cout<<" |------

要用c语言设计一个个人通讯录,要求有步骤的截图,急急急,求大神帮帮忙啊

#include
#include
#include
#defineM3
FILE*fp;
charfn[50]={""};
typedefstructmessage{
charname[20];
charaddress[50];
chartelephone[15];
intpostcode;
structmessage*next;
}*LinkList,*NODE;
voidReadData(NODEp){
printf("姓名:");
scanf("%s",p->name);
printf("地址:");
scanf("%s",p->address);
printf("电话号码:");
scanf("%s",p->telephone);
printf("邮政编码:");
scanf("%d",&p->postcode);
}
voidShowLine(intn){
inti;
for(i=0;i printf("*");
printf("\n");
}
voidShowData(NODEp){
printf("%s",p->name);
printf("%s",p->address);
printf("%s",p->telephone);
printf("%d\n",p->postcode);
}
voidShowAll(LinkListhead){
NODEp;
if(head==NULL)return;
ShowLine(25);
for(p=head->next;p;p=p->next)
ShowData(p);
ShowLine(25);
}
LinkListCreateList(intn){
NODEhead,p;
inti;
head=p=(LinkList)malloc(sizeof(message));
for(i=0;i p->next=(LinkList)malloc(sizeof(message));
printf("(%d/%d)的信息:\n",i+1,n);
ReadData(p->next);
p=p->next;
}
p->next=NULL;
returnhead;
}
voidAddmember(LinkListhead){//头插法添加,可用于创建新链表
NODEp=(LinkList)malloc(sizeof(message));
ReadData(p);
if(head==NULL){
head->next=p;
p->next=NULL;
}
else{
p->next=head->next;
head->next=p;
}
}
NODESearch(LinkListhead,charname[]){
NODEp;
if(head==NULL)returnNULL;
for(p=head->next;p;p=p->next){
if(strcmp(p->name,name)==0)
ShowData(p);
returnp;
}
returnNULL;
}
voidModifyList(LinkListhead){
NODEp;
charname[20];
printf("被修改人的姓名:");
scanf("%s",name);
p=Search(head,name);
if(p==NULL)printf("查无此人。\n");
else{
ShowData(p);
ReadData(p);
}
}
intErase(LinkListhead,charname[]){//删除姓名为name的结点
intan;
NODEp,q;
if(head==NULL)return0;
for(p=head;p->next;p=p->next){
if(strcmp(p->next->name,name)==0){
ShowData(p);
printf("1.删除,0.不删除:");
scanf("%d",&an);
if(an==1){
q=p->next;
p->next=q->next;
free(q);
return1;
}
elsereturn0;
}
}
return0;
}
voidLoadData(LinkListhead){//传送文件的内容到内存
NODEp,tmp;
intan;
if(fn[0]=='\0'){
printf("文件名:");
scanf("%s",fn);
}
else{
printf("加载文件%s?1.是,0不是:",fn);
scanf("%d",&an);
if(an==1){
fp=fopen(fn,"rb");
if(fp==NULL){
printf("打开文件%s失败。\n",fn);
return;
}
}
else{
printf("文件名:");
scanf("%s",fn);
fp=fopen(fn,"rb");
if(fp==NULL){
printf("打开文件%s失败。\n",fn);
return;
}
}
}
if(head==NULL){
head=p=(NODE)malloc(sizeof(message));
tmp=(NODE)malloc(sizeof(message));
while(fread(tmp,sizeof(message),1,fp)==1){
p=(NODE)malloc(sizeof(message));
*p->next=*tmp;
p=p->next;
}
fclose(fp);
p->next=NULL;
free(tmp);
return;
}
printf("1.追加0.覆盖:");
scanf("%d",&an);
if(an==1){
for(p=head->next;p->next;p=p->next);
tmp=(NODE)malloc(sizeof(message));
while(fread(tmp,sizeof(message),1,fp)==1){
p->next=(NODE)malloc(sizeof(message));
*p->next=*tmp;
p=p->next;
}
fclose(fp);
p->next=NULL;
free(tmp);
return;
}
if(an==0){
p=head;
tmp=(NODE)malloc(sizeof(message));
while(p->next){
if(fread(tmp,sizeof(message),1,fp)==1){
*p->next=*tmp;
p=p->next;
}
elsebreak;
}
if(p->next==NULL){
while(fread(tmp,sizeof(message),1,fp)==1){
p->next=(NODE)malloc(sizeof(message));
*p->next=*tmp;
p=p->next;
}
fclose(fp);
p->next=NULL;
free(tmp);
return;
}
free(tmp);
tmp=p->next;
p->next=NULL;
while(tmp->next){
p=tmp->next;
tmp->next=p->next;
free(p);
}
}
}
voidSaveData(LinkListhead){//保存内存到文件
intan;
charmode[5];
NODEp;
if(fn[0]==0){
printf("请输入文件名:");
scanf("%s",fn);
fp=fopen(fn,"wb");
if(fp==NULL){
printf("打开文件%s失败。\n",fn);
return;
}
for(p=head->next;p;p=p->next)
fwrite(p,sizeof(message),1,fp);
fclose(fp);
return;
}
else{
printf("1.覆盖文件%s\n2.追加文件%s\n3.新建\n4.无操作返回\n");
printf("请选择:");
scanf("%d",&an);
if(an<1||an>3)return;
if(an==3){
printf("请输入文件名:");
scanf("%s",fn);
fp=fopen(fn,"wb");
if(fp==NULL){
printf("打开文件%s失败。\n",fn);
return;
}
for(p=head->next;p;p=p->next)
fwrite(p,sizeof(message),1,fp);
fclose(fp);
return;
}
else{
if(an==1)strcpy(mode,"wb");
elseif(an==2)strcpy(mode,"ab");
fp=fopen(fn,"wb");
if(fp==NULL){
printf("打开文件%s失败。\n",fn);
return;
}
for(p=head->next;p;p=p->next)
fwrite(p,sizeof(message),1,fp);
fclose(fp);
return;
}
}
}
voidSort(LinkListhead){//按姓名增排序
NODEp,q,pt;
if(head==NULL)return;
p=head;
while(p->next){
q=p->next->next;
while(q->next){
if(strcmp(p->next->name,q->next->name)>0){
pt=p->next;
p->next=q->next;
q->next=q->next->next;
p->next->next=pt;
}
elseq=q->next;
}
p=p->next;
}
}
voidFreeList(LinkListhead){
NODEp=head,q;
while(p){
q=p;
p=p->next;
free(q);
}
}
voidmenu(LinkListhead){
intchoice,n;
do{
printf("┌─────────────────────────────────┐\n");
printf("││\n");
printf("│欢迎使用通讯录管理软件│\n");
printf("││\n");
printf("│编写xoalyg│\n");
printf("││\n");
printf("└─────────────────────────────────┙\n");
printf("\n\n\n\n");
printf("\t1、新建\n");
printf("\t2、浏览\n");
printf("\t3、修改\n");
printf("\t4、插入\n");
printf("\t5、排序\n");
printf("\t6、加载\n");
printf("\t7、保存\n");
printf("\t0、退出\n");
printf("\n\t请选择:");
scanf("%d",&choice);
switch(choice){
case1:printf("\t人数:");
scanf("%d",&n);
head=CreateList(n);
break;
case2:ShowAll(head);break;
case3:ModifyList(head);break;
case4:Addmember(head);break;
case5:Sort(head);break;
case6:LoadData(head);break;
case7:SaveData(head);break;
case0:break;
}
}while(choice!=0);
}
intmain(){
NODEhead=NULL;
menu(head);
FreeList(head);
return0;
}

求C语言,通讯录编程一份 使用VC++

#include #include #include #include #include //#include using namespace std; string ID;//具有唯一性 class Person { protected: string No; //学号 string Age; char Name[20]; //姓名 char postcode[45]; //邮政编码 char address[60];//家庭住址 string Tel; //联系方式 Pers

C语言编程 小型通讯录

#include #include #include #include #define ID struct id struct id { char name[20]; char tele[20]; ID *next; }; int pc=0; ID *creat() { ID *p1,*p2,*head; char str[20]; p1=p2=head=NULL; printf("\t\t\t 开始输入记录(姓名 # 结束)!\n"); while(1) { printf("请输入姓名:\n");scanf

怎么用C语言编写通讯录啊,请教高手

#include #include #include "address.h" #include "addressList.h" #include "addressBook.h" using namespace std; int main() { new AddressBook; //开启通信录 return 0; } ostream& operator<<(ostream& os, const RecordList& c_rl) { RecordList::const_iterator it; RecordList::const_iterator it_
展开全文阅读