Subscribe Us

Responsive Advertisement

Advertisement

Create link list manually using C

 

Create link list manually using C



#include<stdio.h>

struct node

{

    int data;

    struct node *next;


};

int main()

{

    struct node *a,*b,*c;

    a=NULL;

    b=NULL;

    c=NULL;

    a=(struct node *)malloc(sizeof(struct node));

    b=(struct node *)malloc(sizeof(struct node));

    c=(struct node *)malloc(sizeof(struct node));

    a->data=100;

    b->data=200;

    c->data=300;

    a->next=b;

    b->next=c;

    c->next=NULL;

    while(a!=NULL)

    {

        printf("%d ",a->data);

        a=a->next;

    }




    return 0;

}


Post a Comment

0 Comments