怎么做更简化一些
#include<cstdio>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define LEN sizeof(struct s)
struct s
{
char a;
s *next;
};
int main()
{
s *head,*p1=NULL,*p2=NULL;
head=p2=(struct s*)malloc(LEN);
scanf("%c",&p2->a);
while(p2->a!='\0')
{
p1=p2;
p2=(struct s*)malloc(LEN);
scanf("%c",&p2->a);
p1->next=p2;
}
p2->next=NULL;
p1=head;
while(p1->next!=NULL)
{
printf("%c ",p1->a);
p1=p1->next;
}
return 0;
}