创建单链表并输出

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct Note
{
    char a;
    struct Note* next;
} Note,*list;a
void CF(list L)
{
    Note *s;
    char c;
    int flag = 1;
    while(flag)
    {
        c = getchar();
        getchar();
        if(c != '$')
        {
            s=(Note*)malloc(sizeof(Note));
            s->a=c;
            s->next=L->next;
            L->next=s;
        }
        else 
            flag = 0;
    }
}
int main()
{
    list L,s;
    L=(Note*)malloc(sizeof(Note));
    L->next=NULL;
    CF(L);
    s=L->next;
    while(s->next!=NULL)
    {
        printf("%c ",s->a);
        s=s->next;
    }
    printf("%c\n",s->a);
    return 0;
}
            s->a=c;
            s->next=L->next;
            L->next=s;
注意这三句;
posted @ 2017-10-13 19:28  zcb_bai  阅读(703)  评论(0编辑  收藏  举报