I can not run it successfully
thanks :)
Expand|Select|Wrap|Line Numbers
- #include<stdio.h>
- #include<conio.h>
- #include<stdlib.h>
- #define SIZE 10
- typedef struct dlist
- {
- int val;
- struct dlist *next,*prev;
- }*dll;
- //---------------- FUNCTION SEARCH_VAL --------------------------------------
- dll search_val(dll head,int data)
- {
- dll temp;
- temp=head;
- while(temp)
- {
- if(temp->val==data)
- return(1);
- else
- temp=temp->next;
- }
- return(0);
- }
- //---------------- FUNCTION ADD_BEG -----------------------------------------
- void add_beg(dll head,dll n_new)
- {
- dll temp;
- temp=head;
- while(temp->prev!=NULL)
- temp=temp->prev;
- n_new->next=temp->next;
- temp->next->prev=n_new;
- temp->next=n_new;
- n_new->prev=temp;
- }
- //---------------- FUNCTION ADD_END ----------------------------------------
- void add_end(dll head,dll n_new)
- {
- dll temp;
- temp=head;
- while(temp->next!=NULL)
- temp=temp->next;
- temp->next=n_new;
- n_new->prev=temp;
- n_new->next=NULL;
- }
- //---------------- FUNCTION DELETE ------------------------------------------
- int delete(dll head,int data)
- {
- dll temp;
- temp=head;
- while(temp)
- {
- if(temp->val==data)
- {
- temp->prev->next=temp->next;
- temp->next->prev=temp->prev;
- temp->prev=temp->next->next;
- return(temp->val);
- }
- else
- temp=temp->next;
- }
- return(NULL);
- }
- //---------------- FUNCTION DISPLAY ----------------------------------------
- void display(dll head)
- {
- dll temp;
- printf("\n\n\t THE DOUBLY LINKED LIST IS ::");
- printf("HEAD->");
- temp=head->next;
- while(temp)
- {
- printf("<-%d->",temp->val);
- temp=temp->next;
- }
- printf("NULL");
- }
- //---------------- FUNCTION GET_NODE-----------------------------------------
- dll get_node()
- {
- dll n_new;
- n_new=malloc(sizeof(struct dlist));
- printf("\n\n\t ENTER THE VALUE ::");
- scanf("%d",&n_new->val);
- n_new->next=NULL;
- n_new->prev=NULL;
- return(n_new);
- }
- //---------------- FUNCTION CREATE ------------------------------------------
- dll create()
- {
- dll head,n_new,last;
- char c;
- head=malloc(sizeof(struct dlist));
- head->next=NULL;
- head->prev=NULL;
- last=head;
- do
- {
- n_new=malloc(sizeof(struct dlist));
- printf("\n\n\t ENTER THE VALUE ::");
- scanf("%d",&n_new->val);
- last->next=n_new;
- n_new->prev=last;
- n_new->next=NULL;
- last=n_new;
- printf("\n\n\t CREATE ANY MORE NODE (Y/N) ::");
- c=getche();
- }while(c=='y'||c=='Y');
- return(head);
- }
- //--------------------------------------------------------------------------
- void main()
- {
- dll head,n_new;
- int choice,data;
- char c;
- // textcolor(14);
- while(1)
- {
- //clrscr();
- printf("\n\n\t THE DOUBLY LINKED LIST OPERATION :: ");
- printf("\n\n\t 1> CREATE LIST");
- printf("\n\n\t 2> DISPLAY");
- printf("\n\n\t 3> ADD AT END");
- printf("\n\n\t 4> ADD AT BEGINING");
- printf("\n\n\t 5> SEARCH");
- printf("\n\n\t 6> DELETE");
- printf("\n\n\t 7> EXIT");
- printf("\n\n\t ENTER YOUR CHOICE ::");
- scanf("%d",&choice);
- switch(choice)
- {
- case 1:head=create();
- display(head);
- break;
- case 2:display(head);
- break;
- case 3:new=get_node();
- add_end(head,n_new);
- display(head);
- break;
- case 4:n_new=get_node();
- add_beg(head,n_new);
- display(head);
- break;
- case 5:printf("\n\n\t ENTER THE VALUE TO BE SEARCHED :: ");
- scanf("%d",&data);
- if(search_val(head,data))
- {
- printf("\n\n\t THE VALUE IS PRESENT IN THE LIST ");
- display(head);
- }
- else
- {
- printf("\n\n\t THE VALUE IS NOT PRESENT IN THE LIST ");
- display(head);
- }
- break;
- case 6:printf("\n\n\t ENTER THE VALUE TO BE DELETED ::");
- scanf("%d",&data);
- if(search_val(head,data))
- {
- data=delete(head,data);
- printf("\n\n\t THE DATA DELETED FROM THE LIST IS :: %d",data);
- display(head);
- }
- else
- {
- if(head->next==NULL)
- {
- printf("\n\n\t THE LIST IS EMPTY ");
- display(head);
- }
- else
- {
- printf("\n\n\t THE DATA IS NOT PRESENT IN THE LIST ");
- display(head);
- }
- }
- break;
- case 7:printf("\n\n\t PRESS ESC TO EXIT ");
- if(getch()==27)
- exit(0);
- break;
- }
- getch();
- }
- }
- //--------------------------------------------------------------------------*/
In function `dlist* search_val(dlist*, int)':
19 .invalid conversion from `int' to `dlist*'
19 At global scope:
50 expected unqualified-id before "delete"
......