69,371
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <malloc.h>
typedef char datatype;
typedef struct node
{
datatype data;
struct node* next;
}linklist;
int main(int argc, char* argv[])
{
char ch;
linklist *head, *s;
head = NULL;
ch = getchar();
while(ch!='$')
{
s = (struct node*)malloc(sizeof(linklist));
s->data =ch;
s->next = head;
head = s;
ch = getchar();
}
struct node* p = head;
int i = 1;
while(p)
{
printf("第%d个节点数据为:%c\n", i, p->data);
p = p->next;
i++;
}
getchar();
return 0;
}