Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- struct node
- {
- char data[60];
- struct node *prev;
- struct node *next;
- };
- struct node *head=NULL;
- struct node *last=NULL;
- struct node *current=NULL;
- void insert(char* data)
- {
- struct node *temp=(struct node*)malloc(sizeof(struct node));
- strcpy(temp->data,data);
- temp->prev=NULL;
- temp->next=NULL;
- if(head==NULL)
- {
- head=temp;
- return;
- }
- current=head;
- while(current->next!=NULL)
- {
- current=current->next;
- }
- current->next=temp;
- last=temp;
- temp->prev=current;
- }
- void print()
- {
- struct node *ptr=head;
- printf("linked list is : ");
- while(ptr->next!=NULL)
- {
- printf("%s ",ptr->data);
- ptr=ptr->next;
- }
- printf("%s",ptr->data);
- }
- void main()
- {
- insert("susri");
- insert("rowshon");
- print();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment