C语言链表
输入asdf....无限输出S可能是主函数的问题。。。。
#include<stdio.h>
#include<stdlib.h>
struct student
{
char name;
char numb[10];
struct student *next;
} ;
struct student *lll()
{
char c;
int i=1;
struct student *head;
struct student *pa,*pb;
head->next =NULL;
pa=pb=(struct student *)malloc(sizeof(struct student));
c=getchar();
while(i!=3)
{
pa->name =c;
pa->next =head->next ;
head->next=pa;
c=getchar();
i++;
}
return head;
}
main()
{
int i;
struct student *h;
/*char *a=(char *)calloc(26,sizeof(char));
char *b=(char *)calloc(26,sizeof(char));
for(i=0;i<26;i++)
{
a[i]=65+i;
b[i]=97+i;
}
puts(a);
puts(b);*/
h=lll();
for(;h->name !=NULL ;)
{
printf("%c",h->name );
h=h->next ;
}
}