LINKED LIST IN C
#include<stdio.h>
#include<stdlib.h>
struct node{
int data;
struct node *next;
};
void printlinkedlist(struct node *p){
while(p!=NULL){
printf("%d",p->data);
p=p->next;
}
}
int main(){
struct node *head;
struct node *one=NULL;
struct node *two=NULL;
struct node *three=NULL;
//allocate memory
one=malloc(sizeof(struct node));
two=malloc(sizeof(struct node));
three=malloc(sizeof(struct node));
//assign value
one->data=1;
two->data=2;
three->data=3;
//connect nodes
one->next=two;
two->next=three;
three->next=NULL;
//printing node
head=one;
printlinkedlist(head);
}
LINKED LIST IN C
Reviewed by Shubham Prajapati
on
June 26, 2023
Rating:
No comments:
If you have any doubt so you can comment me then i will 100% help you ,Through comment Chat