静态链表

下面是一个静态链表的简单例子, 打印出几个节点内容

#include <stdio.h>
#include <iostream>

using namespace std;

typedef struct stu{
    int value;      
    struct stu* next;
}ST;

int main()
{
    ST s1,s2,s3,s4,s5,s6;
    s1.value = 1;
    s2.value = 2;
    s3.value = 3;
    s4.value = 4;
    s5.value = 5;
    s6.value = 6;

    s1.next = &s2;      
    s2.next = &s3;
    s3.next = &s4;
    s4.next = &s5;
    s5.next = &s6;
    s6.next = NULL;

    ST* head = &s1;
    while(head)
    {
        cout << head->value << endl;
        head = head->next;
    }
    return 0;
}
原文地址:https://www.cnblogs.com/nanqiang/p/9966371.html