我又哭了,为什么输出的时候多了个问号?
#include<stdio.h>#include<malloc.h>
typedef char datatype;
typedef struct node
{
datatype data;
struct node *next;
}Linklist;
main()
{
char ch;
Linklist *head,*s,*r;
r = (Linklist*)malloc(sizeof(Linklist));
head = r;
scanf("%c",&ch);
while(ch != '$')
{
s = (Linklist *)malloc(sizeof(Linklist));
s->data = ch;
r->next = s;
r = s;
scanf("%c",&ch);
}
r->next = NULL;
s = head;
while(s->next != NULL)
{
printf("%c ",s->data);
s = s->next;
}
printf("%c ",s->data);
getchar();
}