Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- struct temp{
- int x;
- struct temp *pt;
- }*start=NULL;
- void create()
- {
- struct temp *ptr,*c;
- for(int i=1;i<=3;i++)
- {
- ptr=(struct temp*)malloc(sizeof(struct temp));
- ptr->x=i;
- ptr->pt=NULL;
- if(start==NULL)
- {
- start=ptr;
- c=ptr;
- }
- else{
- c->pt=ptr;
- c=ptr;
- }
- }
- }
- void display()
- {
- struct temp *ptr=start;
- int k=0;
- while(k!=4)
- {
- printf("%d ",ptr->x);
- ptr=ptr->pt;k++;
- }
- }
- void l_insert()
- {
- struct temp *ptr=start,*c;
- for(int i=2;i<=3;i++)
- {
- ptr=ptr->pt;
- }
- c=(struct temp*)malloc(sizeof(struct temp));
- c->x=5;
- c->pt=start;
- ptr->pt=c;
- }
- int main()
- {
- create();
- //display();
- l_insert();
- display();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement