这个程序怎么有问题?请指教!
#include"stdio.h"
#include"stdlib.h"
struct node
{
char data;
struct node *next;
};
typedef struct node Node;
void reserse_print(Node *);
main()
{
Node *h=NULL,*p1,*p2;
printf("input char to create a list\n");
p1= (Node *)malloc(sizeof(Node));
scanf("%s",&p1->data);
if(p1->data!='\n')
h=p1;
while(p1->data!='\n'){
p2=p1;
p1=(Node *)malloc(sizeof(Node));
scanf("%s",&p1->data);
p2->next=p1;
}
p2->next=NULL;
reserse_print(h);
return 0;
}
void reserse_print(Node *p)
{
if(p!=NULL)
reserse_print(p->next);
printf("%s",p->data);
}
编译没错,但输入字符时好象没有条件使它停止。请教!