Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- typedef struct node
- {
- int a;
- char ch;
- struct node*next;
- struct node*previous;
- } node;
- node*head;
- void display()
- {
- node *list=head;
- while(list !=NULL)
- {
- printf("A: %d\n",list->a);
- printf("C: %c\n",list->ch);
- printf("\n");
- list=list->next;
- }
- }
- void insert_at_first(int aN, char chN)
- {
- node *N=(node*)malloc(sizeof(node));
- N->a=aN;
- N->ch=chN;
- N->next=NULL;
- N->previous=NULL;
- if(head==NULL)
- {
- head=N;
- return;
- }
- N->next=head;
- head->previous=N;
- head=N;
- }
- int main()
- {
- head=NULL;
- insert_at_first(1,'A');
- insert_at_first(3,'b');
- insert_at_first(5,'c');
- insert_at_first(7,'d');
- insert_at_first(9,'e');
- display();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement