Create Linked Lists with structure and pointer - C Data Structure

C examples for Data Structure:Linked List

Description

Create Linked Lists with structure and pointer

Demo Code

#include <stdio.h>

struct Node{/*from   w  w w. j a  v  a2 s  .  co  m*/
        int value;
        struct Node *next;
};

int main (void){

    struct Node n1, n2, n3;
    int i;

    n1.value = 1;
    n2.value = 2;
    n3.value = 3;

    n1.next = &n2;
    n2.next = &n3;

    i = n1.next->value;
    printf ("%i  ", i);

    printf ("%i\n", n2.next->value);

    return 0;
}

Result


Related Tutorials