Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- struct node
- {
- int data;
- char Name[40];
- struct node* link;
- };
- struct node* head=NULL;
- void insert()
- {
- struct node* temp=(struct node*)malloc(sizeof(struct node));
- temp->data=1001;
- strcpy(temp->Name,"Karim");
- temp->link=NULL;
- head=temp;
- struct node* temp1=(struct node*)malloc(sizeof(struct node));
- temp1->data=1002;
- strcpy(temp1->Name,"Rahim");
- temp1->link=NULL;
- struct node*p=head;
- p->link=temp1;
- }
- display()
- {
- struct node* p=head;
- printf("1st-ID = %d ",p->data);
- printf("Name: %s ",p->Name);
- p=p->link;
- printf(" 2nd-ID = %d ",p->data);
- printf("Name: %s ",p->Name);
- }
- int main()
- {
- insert();
- display();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement