#include<stdio.h>
#include<stdlib.h>
struct demo
{
char str[15];
struct damo* pnext;
};
struct demo* create()
{
struct demo* pnew,*pend,*phead;
pnew=pend=(struct demo*)malloc(sizeof(struct demo));
phead=pnew;
printf("请输入文字");
scanf("%s",phead->str);
if(*(phead->str)!="\n");
{
for(;;)
{
pnew=(struct demo*)malloc(sizeof(struct demo));
pend->pnext=pnew;
printf("请输入文字");
scanf("%s",pnew->str);
if(*(pend->str)=="\n")
{
break;
}
pend=pnew;
}
}
pend->pnext=NULL;
return phead;
}
void main()
{
struct demo* phead;
struct demo* pprint;
phead=create();
printf("\n输出为:\n");
pprint=phead;
printf("%s",*(pprint->str));
for(;;)
{
pprint=pprint->pnext;
printf("%s",*(pprint->str));
if(pprint==NULL)
{
break;
}
}
}
链表可以正常输入,但是当输入回车退出输入的循环后,就无法正常输出了,求解答,谢谢