Create a simple linked list

 Create a simple linked list


#include <stdio.h>
#include <stdlib.h>

struct Node

{
    int data;
    struct Node *next; /* data */
};

int main()
{

    struct Node *head = NULL;
    struct Node *second = NULL;
    struct Node *thrid = NULL;

    head = (struct Node *)malloc(sizeof(struct Node));
    second = (struct Node *)malloc(sizeof(struct Node));
    thrid = (struct Node *)malloc(sizeof(struct Node));

    head->data = 1;
    head->next = second;

    second->data = 2;
    second->next = thrid;

    thrid->data = 3;
    thrid->next = NULL;

    // printlist(head);






}




Post a Comment

0 Comments