链表结构理解

#include <stdio.h>
#include <malloc.h>
struct node
{
    int date;
    struct node *next;
};
int main()
{
    struct node a,b,c,*head,*p;
    a.date=1;
    b.date=2;
    c.date=3;
    head=&a;    //head 存a的地址
    a.next=&b;  
    b.next=&c;
    c.next=NULL;
    p=head;
    do
    {
        printf("%d\n",p->date); //->表示地址指向
        p=p->next;
    }while(p);
    return 0;
}

 

posted @ 2022-04-24 21:51  xxj112  阅读(24)  评论(0)    收藏  举报