请教高手,指出错误,感谢啦
#include"stdio.h"#include"malloc.h"
int main()
{ typedef struct node{
char data;
struct node*next;
}LinkList;
LinkList *head,*s,*r,*letter,*digital,*other,*q,*p1,*p2,*p3;
char ch;
head=(LinkList*)malloc(sizeof(LinkList));
digital=(LinkList*)malloc(sizeof(LinkList));
letter=(LinkList*)malloc(sizeof(LinkList));
other=(LinkList*)malloc(sizeof(LinkList));
r=head;
while (ch!='$'){
s=(LinkList *)malloc(sizeof(LinkList));//创建结点放入字符
s->data=ch;
r->next=s; //
r=s; //
ch=getchar();
}
r->next=NULL;
q=head->next;
p1=digital;
p2=letter;
p3=other;
do{if((q->data>='0')&&(q->data<='9'))//选出数字字符
{ head->next=q->next;
p1->next=q;
p1=p1->next;
q=head->next;
}
else if(((q->data>='a')&&(q->data<='z'))||((q->data>='A')&&(q->data<='Z')))//选出字母字符
{
head->next=q->next;
p2->next=q;
p2=p2->next;
q=head->next;
}
else {
head->next=q->next;
p3->next=q;
p3=p3->next;
q=head->next;
}
}while(q!=NULL);
while(digital!=NULL){ //分别输出三个链表
printf("%C ",digital->data);
digital=digital->next;}
printf("\n");
while(letter!=NULL){
printf("%C ",letter->data);
letter=letter->next;}
printf("\n");
while(other!=NULL){
printf("%C ",other->data);
other=other->next;}
printf("\n");
}