1. 程式人生 > >創建單鏈表並輸出

創建單鏈表並輸出

struct not col eof return pan string tdi null

#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;
註意這三句;

創建單鏈表並輸出