include<stdio.h>
#include<conio.h>
#include<alloc.h>
struct node
{
int data;
struct node* next;
};
struct node* temp,*p,*head=NULL,*t,*n;
int no,position,i;
void create();
void infirst();
void inmid();
void inlast();
void delfirst();
void delmid();
void dellast();
void display();
void create()
{
for (i=0;i<4;i++)
{
if (head==NULL)
{
{
temp=malloc(sizeof(struct node));
printf("enter the no");
scanf("%d",&no);
temp->data=no;
temp->next=NULL;
head=temp;
}
else
{
p=malloc(sizeof (struct node));
printf("enter the no");
scanf("%d",&no);
p->data=no;
p->next=NULL;
p->next=head;
head=p;
}
}
}
void inmid()
{
n=malloc(sizeof (struct node));
printf("enter the no");
scanf("%d",&no);
n->data=no;
n->next=NULL;
printf("enter the position");
scanf("%d",&position);
temp=head;
i=1;
while(i<position)
{
p=temp;
temp=p->next;
i++;
}
p->next=n;
n->next=temp;
}
void infirst()
{
t=malloc(sizeof (struct node));
printf("enter the no");
scanf("%d",&no);
t->data =no;
t->next=head;
p=head;
head=t;
}
void inlast()
{
t=malloc (sizeof (struct node));
printf("enter the no");
scanf("%d",&no);
t->data=no;
t->next=NULL;
temp=head;
while(temp->next!=NULL)
{
temp=temp->next;
}
temp->next=t;
}
void delfirst()
{
t=head;
head=t->next;
free(t);
}
void delmid()
{
temp=head;
i=1;
while(i<position)
{
p=temp;
temp=p->next;
i++;
}
p->next=temp->next;
t=temp;
free(t);
}
void dellast()
{
temp=head;
while(temp->next!NULL)
{
p=temp;
temp=p->next;
}
p->next=NULL;
free(temp);
}
void display()
{
for(temp=head;temp->next!=NULL;temp=te...
{
printf("%d",temp->data);
}
printf("\n****");
}
void main()
{
int choice;
do
{
printf("\n **MENU**");
printf("\n1.creation \n2.insert first \n3.insert middle \n4.insert last \n5.delete first \n6.delete middle \n7.last \n8.display");
printf(" \n enter the choice");
scanf("%d",& choice);
switch(choice)
{
case 1:
create();
display();
break;
case 2:
infirst();
display();
break;
case 3:
inmid();
display();
break;
case 4:
inlast();
display();
break;
case 5:
delfirst();
display();
break;
case 6:
delmid();
display();
break;
case 7:
dellast();
display();
break;
default:
printf("invalid choice");
}
}
while (choice!=8)
getch();
}
ERROR: line 26: cannot covert 'void *' to 'node *'
line 33:misplaced else
line 35: cannot covert 'void *' to 'node *'
line 46: declaration syntax error
line 174:(last line) : declaration missing ;
line 174: compound statement missing }
Tags: