大家帮我看看错在那里了啊!
/* Note:Your choice is C IDE */#include "stdio.h"
#include<malloc.h>
typedef struct node
{
char ch;
struct node *next;
}linkstr;
linkstr *creat(char *ch)
{
linkstr *p,*head,*q;
int i=0;
p=head=(linkstr *)malloc(sizeof(linkstr));
head->next=NULL;
while(ch[i]!=0)
{
q=(linkstr *)malloc(sizeof(linkstr));
p->ch=ch[i];
p->next=q;
q->next=NULL;
p=q;i++;
}
return head;
}
void output(linkstr *head)
{
linkstr *p;
p=head->next;
while(p)
{
printf("%c",p->ch);
p=p->next;
}
}
void main()
{
linkstr *head;
int i;char str;
head=(linkstr *)malloc(sizeof(linkstr));
for(i=0;i<10;i++)
{
scanf("%c",&str);
head=creat(&str);
}
output(head);
}
[[it] 本帖最后由 wangyinshiwo 于 2008-5-8 14:10 编辑 [/it]]
[[it] 本帖最后由 wangyinshiwo 于 2008-7-20 20:50 编辑 [/it]]