网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

c语言通讯函数 c语言通信协议

大神看看我的C语言通讯录查找函数。输入电话号码查找永远是未查找到

这段代码没有问题

创新互联是专业的遵化网站建设公司,遵化接单;提供成都做网站、成都网站制作、成都外贸网站建设,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行遵化网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!

你需要检查一下链表的数据内容,在调用本函数前,用输出语句先遍历一下链表看一下内容吧,估计是建表有问题,或是输入的数据存储不正确。

c语言问题,我正在做一个通讯录,这段函数是提取的,好像有问题。

#include"stdio.h"#include"string.h"#include"stdlib.h"typedefstruct{//通讯录结点类型charnum[5];//编号charname[9];//姓名charsex[3];//性别charphone[13];//电话charaddr[31];//地址}DataType;typedefstructnode{//结点类型定义DataTypedata;//结点数据域structnode*next;//结点指针域}ListNode;typedefListNode*LinkList;LinkListhead;ListNode*p;//函数说明intmenu_select();LinkListCreateList(void);voidInsertNode(LinkListhead,ListNode*p);ListNode*ListFind(LinkListhead);voidDelNode(LinkListhead);voidprintList(LinkListhead);//主函数voidmain(){for(;;){switch(menu_select()){case1:printf("**********************************\n");printf("*通讯录链表的建立*\n");printf("**********************************\n");head=CreateList();break;case2:printf("**********************************\n");printf("*通讯者信息的添加*\n");printf("**********************************\n");printf("编号(4)姓名(8)性别(3)电话(11)地址(31)\n");printf("*************************************\n");p=(ListNode*)malloc(sizeof(ListNode));//申请新结点scanf("%s%s%s%s%s",p-data.num,p-data.name,p-data.sex,p-data.phone,p-data.addr);InsertNode(head,p);break;case3:printf("***********************************\n");printf("*通讯录信息的查询*\n");printf("***********************************\n");p=ListFind(head);if(p!=NULL){printf("编号姓名性别联系电话地址\n");printf("--------------------------------------------------\n");printf("%s,%s,%s,%s,%s\n",p-data.num,p-data.name,p-data.sex,p-data.phone,p-data.addr);printf("---------------------------------------------------\n");}elseprintf("没有查到要查询的通讯者!\n");break;case4:printf("***********************************\n");printf("*通讯录信息的删除*\n");printf("***********************************\n");DelNode(head);//删除结点break;case5:printf("************************************\n");printf("*通讯录链表的输出*\n");printf("************************************\n");printList(head);break;case0:printf("\t再见!\n");return;}}}/*******************//*菜单选择函数程序*//***************************/intmenu_select(){intsn;printf("通讯录管理系统\n");printf("===================\n");printf("1.通讯链表的建立\n");printf("2.通讯者结点的插入\n");printf("3.通讯者结点的查询\n");printf("4.通讯者结点的删除\n");printf("5.通讯录链表的输出\n");printf("0.退出管理系统\n");printf("==========================\n");printf("请选择0-5:");for(;;){scanf("%d",sn);if(sn5)printf("\n\t输入错误,重选0-5:");elsebreak;}returnsn;}/**************************//*用尾插法建立通讯录链表函数*//**************************/LinkListCreateList(void){//尾插法建立带头结点的通讯录链表算法LinkListhead=(ListNode*)malloc(sizeof(ListNode));//申请头结点ListNode*p,*rear;intflag=0;//结束标志置0rear=head;//尾指针初始指向头结点while(flag==0){p=(ListNode*)malloc(sizeof(ListNode));//申新结点printf("编号(4)姓名(8)性别电话(11)地址(31)\n");printf("--------------------------------------------------------------------------------------\n");scanf("%s%s%s%s%s",p-data.num,p-data.name,p-data.sex,p-data.phone,p-data.addr);rear-next=p;//新结点连接到尾结点之后rear=p;//尾指针指向新结点printf("结束建表吗?(1/0):");scanf("%d",flag);}rear-next=NULL;//终端结点指针置空returnhead;//返回链表头指针}/******************************//*在通讯录链表head中插入结点*//******************************/voidInsertNode(LinkListhead,ListNode*p){ListNode*p1,*p2;p1=head;p2=p1-next;while(p2!=NULLstrcmp(p2-data.num,p-data.num)next;//p2指向表的下一个结点}p1-next=p;//插入p所指向的结点p-next=p2;//连接表中剩余的结点}/******************************************//*有序通讯录链表的查找*//******************************************/ListNode*ListFind(LinkListhead){//有序通讯录链表上的查找ListNode*p;charnum[5];charname[9];intxz;printf("==================\n");printf("1.按编号查询\n");printf("2.按姓名查询\n");printf("==================\n");printf("请选择:");p=head-next;//假定通讯录表带头结点scanf("%d",xz);if(xz==1){printf("请输入要查找者的编号:");scanf("%s",num);while(pstrcmp(p-data.num,num)next;if((p==NULL)||strcmp(p-data.num,num))0;p=NULL;//没有查到要查找的通讯者}elseif(xz==2){printf("请输入要查找者的姓名:");scanf("%s",name);while(pstrcmp(p-data.name,name)!=0)p=p-next;}returnp;}/*******************************//*通讯录链表上的结点删除*//*********************************/voidDelNode(LinkListhead){charjx;ListNode*p,*q;p=ListFind(head);//调用查找函数if(p==NULL){printf("没有查到要删除的通讯者!\n");return;}printf("真的要删除该结点吗?(y/n):");scanf("%c",jx);if(jx=='y'||jx=='Y'){q=head;while((q!=NULL)(q-next!=p))q=q-next;q-next=p-next;//删除结点free(p);//释放被删结点空间printf("通讯者已被删除!\n");}}/**********************************//*通讯录链表的输出函数*//**********************************/voidprintList(LinkListhead){ListNode*p;p=head-next;printf("编号姓名性别联系电话地址\n");printf("--------------------------------------------------------------------------------\n");while(p!=NULL){printf("%s,%s,%s,%s,%s\n",p-data.num,p-data.name,p-data.sex,p-data.phone,p-data.addr);printf("---------------------------------------------------------------------------------\n");p=p-next;//后移一个结点}}

用C语言编写通讯录时用到哪些库函数啊?

"gotoxy()","moveto()"包含在#include conio.h中了.

转载一个程序给你:(ZT)

算法:将当前时间显示到屏幕,当时间发生变化时,清屏,显示新的时间(当有键盘操作时退出程序)。

显示时间格式:小时:分钟:秒

/* DEV C++ Win XP*/

#include stdio.h

#include stdlib.h

#include conio.h

#include time.h

typedef struct

{

int x;

int y;

}Point;

time_t now;

struct tm *pt,t1,t2;

int printpoint(Point p)

{

Point p1;

p1.x=p.x+2; p1.y=p.y+4;

gotoxy(p1.x,p1.y); printf("%c%c",2,2);

gotoxy(p1.x, p1.y+1); printf("%c%c",2,2);

p1.y+=4;

gotoxy(p1.x,p1.y); printf("%c%c",2,2);

gotoxy(p1.x,p1.y+1); printf("%c%c",2,2);

return 0;

}

int print0(Point p)

{

int i=0;

for(;i13;i++)

{

gotoxy(p.x+1, p.y+i);

if(i==0¦¦i==12)

printf("%c%c%c%c%c%c",2,2,2,2,2,2);

else

printf("%c%4s%c",2," ",2);

}

return 0;

}

int print1(Point p)

{

int i=0;

for(;i13;i++)

{

gotoxy(p.x+1, p.y+i);

printf("%5s%c"," ",2);

}

return 0;

}

int print2(Point p)

{

int i=0;

for(;i13;i++)

{

gotoxy(p.x+1, p.y+i);

if(i==0¦¦i==6¦¦i==12)

printf("%c%c%c%c%c%c",2,2,2,2,2,2);

else if(i0i6)

printf("%5s%c"," ",2);

else

printf("%c",2);

}

return 0;

}

int print3(Point p)

{

int i=0;

for(;i13;i++)

{

gotoxy(p.x+1, p.y+i);

if(i==0¦¦i==6¦¦i==12)

printf("%c%c%c%c%c%c",2,2,2,2,2,2);

else

printf("%5s%c"," ",2);

}

return 0;

}

int print4(Point p)

{

int i=0;

for(;i13;i++)

{

gotoxy(p.x+1, p.y+i);

if(i6) printf("%c%4s%c",2," ",2);

else if(i==6)

printf("%c%c%c%c%c%c",2,2,2,2,2,2);

else printf("%5s%c"," ",2);

}

return 0;

}

int print5(Point p)

{

int i=0;

for(;i13;i++)

{

gotoxy(p.x+1, p.y+i);

if(i==0¦¦i==6¦¦i==12)

printf("%c%c%c%c%c%c",2,2,2,2,2,2);

else if(i0i6)

printf("%c",2);

else

printf("%5s%c"," ",2);

}

return 0;

}

int print6(Point p)

{

int i=0;

for(;i13;i++)

{

gotoxy(p.x+1, p.y+i);

if(i==0¦¦i==6¦¦i==12)

printf("%c%c%c%c%c%c",2,2,2,2,2,2);

else if(i0i6)

printf("%c",2);

else

printf("%c%4s%c",2," ",2);

}

return 0;

}

int print7(Point p)

{

int i=0;

for(;i13;i++)

{

gotoxy(p.x+1, p.y+i);

if(i==0) printf("%c%c%c%c%c%c",2,2,2,2,2,2);

else printf("%5s%c"," ",2);

}

return 0;

}

int print8(Point p)

{

int i=0;

for(;i13;i++)

{

gotoxy(p.x+1, p.y+i);

if(i==0¦¦i==6¦¦i==12)

printf("%c%c%c%c%c%c",2,2,2,2,2,2);

else printf("%c%4s%c",2," ",2);

}

return 0;

}

int print9(Point p)

{

int i=0;

for(;i13;i++)

{

gotoxy(p.x+1, p.y+i);

if(i==0¦¦i==6¦¦i==12)

printf("%c%c%c%c%c%c",2,2,2,2,2,2);

else if(i0i6)

printf("%c%4s%c",2," ",2);

else

printf("%5s%c"," ",2);

}

return 0;

}

int clear(Point p)

{

int i=0;

for(;i13;i++)

gotoxy(p.x,p.y+i); printf("%16s"," ");

return 0;

}

int printtime(Point p, int n)

{

int a,b;

Point pp;

a=n/10, b=n%10;

pp.x=p.x+8, pp.y=p.y;

switch(a)

{

case 0: print0(p); break;

case 1: print1(p); break;

case 2: print2(p); break;

case 3: print3(p); break;

case 4: print4(p); break;

case 5: print5(p); break;

}

switch(b)

{

case 0: print0(pp); break;

case 1: print1(pp); break;

case 2: print2(pp); break;

case 3: print3(pp); break;

case 4: print4(pp); break;

case 5: print5(pp); break;

case 6: print6(pp); break;

case 7: print7(pp); break;

case 8: print8(pp); break;

case 9: print9(pp); break;

}

return 0;

}

int main()

{

Point phour, pmin, psec,point1,point2;

phour.x=9, pmin.x=32, psec.x=55;

phour.y=pmin.y=psec.y=7;

point1.x=25, point2.x=49;

point1.y=point2.y=7;

clrscr();

textbackground(BLUE);

textcolor(YELLOW);

now=time(0);

pt=localtime(now);

t1=*pt;

printtime(phour, t1.tm_hour);

printpoint(point1);

printtime(pmin, t1.tm_min);

printpoint(point2);

printtime(psec, t1.tm_sec);

while(1)

{

now=time(0);

pt=localtime(now);

t2=*pt;

if(t2.tm_sec!=t1.tm_sec)

{

t1=t2;

clrscr();

printtime(phour, t1.tm_hour);

printpoint(point1);

printtime(pmin, t1.tm_min);

printpoint(point2);

printtime(psec, t1.tm_sec);

}

if(bioskey(1)==0) continue;

else exit(0);

}

return 0;

}


标题名称:c语言通讯函数 c语言通信协议
标题链接:http://bjjierui.cn/article/dopioeo.html

其他资讯