c语言清空缓冲区函数源码,怎么清空缓冲区?清空缓冲区是什么意思?

怎么清空缓冲区?清空缓冲区是什么意思?

#include

#include

typedef struct LNode

{

char s;

struct LNode *next;

}Node,*LinkList;

LinkList L1;/*定义a 串的末字符的尾指针*/

LinkList Creat1(int n) /*创建表a的函数*/

{

LinkList p,q;

int i;

L1=(Node*)malloc(sizeof (Node));

L1->next=NULL;

q=L1;

for(i=n;i>0;--i)

{p=(Node*)malloc(sizeof (Node));

scanf("%c",p->s);

L1->next=p;

L1=L1->next;/*找到a 串的末字符的尾指针*/

}

L1->next=NULL;

return q;

}

LinkList Creat2(int n) /*创建表b的函数*/

{

LinkList L,p,q;

int i;

L=(Node*)malloc(sizeof (Node));

L->next=NULL;

q=L;

for(i=n;i>0;--i)

{p=(Node*)malloc(sizeof (Node));

scanf("%c",p->s);

L->next=p;

L=L->next;/*找到a 串的末字符的尾指针*/

}

L->next=NULL;

return q;

}

void print(LinkList C)

{

while(C!=NULL)

{

printf("%c\n",C->s);

C=C->next;

}

}

/*找两个字符串的并集,将b中与a不同的连到a的后面。合成一个并集*/

LinkList Merge(LinkList ha,LinkList hb,LinkList t)

{ LinkList r;

for(hb=hb->next;hb!=NULL;hb=hb->next)

{ for(r=ha->next;r!=t->next;r=r->next)

if(r->s != hb->s)

{t->next=hb;

t=t->next;

break;

}

}

t->next=NULL;

return ha->next;

}

main()

{ int x,y;

LinkList hA,hB,hc;

printf("InPut A NO:\n");/*Input a串数*/

scanf("%d",&x);

printf("Input a:\n");/*Input a串*/

hA= Creat1(x);

printf("InPut B NO:\n"); /*Input b串数*/

scanf("%d",&y);

printf("Input b:\n"); /*Input b串*/

hB= Creat2(y);

hc=Merge( hA, hB, L1);

print(hc);

getch();

}

/*出现的问题是我不会清空缓冲区,所以结果是乱码*/

[此贴子已经被作者于2006-4-18 1:07:51编辑过]

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值