erros and solution
Code:
............
scanf("%d", &choice);
getchar();//add this for "garbage" collection
switch(choice){
...........
Code:
case 4:
display();
break;//add this otherwise when it finishes it will go to case 5 and exit.
case 5:
Code:
void delete1();//change the name delete because it exists in c++ compilers
............
void delete1(){
........
}
Code:
void display(){//i think this look better
temp = head;
if(head==NULL){
printf("Doubly Linked List empty\n");
}
else{
printf("\nNULL ");
while(temp!=NULL){
printf("<- %d ->", temp->info);
temp = temp->next;
}
printf("NULL\n");
}
}
Code:
void append(){//do not forget malloc
int x;
printf("Enter element you wish to push\n");
scanf("%d", &x);
getchar();
temp=(struct dll *)malloc(sizeof(struct dll));
temp->info = x;
if(head==tail && head==NULL){
temp->next = NULL;
temp->prev = NULL;
head=temp;
tail = temp;
}else{
tail->next = temp;
temp->prev = tail;
temp->next = NULL;
tail = temp;
}
}
also since its a double list you want 2 display functions
a)from head to tail (the one you wrote)
b)from tail to head
Code:
void display2(){//b)from tail to head
temp = tail;
if(tail==NULL){
printf("Doubly Linked List empty\n");
}
else{
printf("\nNULL ");
while(temp!=NULL){
printf("<- %d ->", temp->info);
temp = temp->prev;
}
printf("NULL\n");
}
}
with this try to correct the other mistakes you have done.