I have written a code for deleting certain value from linklist;
it's not working; where as i have written one for deleting a no., after given no. which works fine! I even debugged it; but invain;
down here am posting my code; please somebody who can point it out; let me know fast; whats wrong in it...
[code=c]
//Delete a number next to the given number
void afterdelete()
{
struct linklist*temp=N ULL;
int no=0;
temp=(struct linklist*)mallo c(sizeof(struct linklist));
printf("\nEnter the no. whose next no. you want to delete.\n");
scanf("%d",&no) ;
if(no!=NULL && first!=NULL && first->next!=NULL)
{
temp=first;
while(temp->value!=no && temp->next!=NULL)
{
temp=temp->next;
}
if(temp->value==no && temp->next!=NULL)
{
temp->next=temp->next->next;
printf("\nThe edited list is as follows:\n");
display(first);
}
else
{
if(temp->value==no && temp->next==NULL)
{
printf("\nThere is no no. to be deleted after the required no.\n");
}
if(temp->value!=no && temp->next==NULL)
{
printf("\nNo. whose next no. you want to delete is not in the list.\n");
}
}
}
else
{
printf("\nEnter the valid input!\n");
}
}
FOR DELETING A NO., WHICH IS NOT WORKING
//Deleting a number from given list; General deletion
void deletion()
{
int d_no=0;
struct linklist* use=NULL;
use=(struct linklist*)mallo c(sizeof(struct linklist));
printf("\nEnter the number you wish to delete:\n");
scanf("\n%d",&d _no);
if(d_no!=NULL && first!=NULL)
{
use=first;
while(d_no!=use->value && use->next!=NULL)
{
use=use->next;
}
if(d_no==use->value)
{
use=use->next;
printf("\nThe edited list is as follows:\n");
display(first);
}
else
{
printf("\nThe number which you wish to delete is not in the list!\n");
}
}
else
{
printf("\nEnter the valid input.\n");
}
[/code]
}
Waiting for answers.
it's not working; where as i have written one for deleting a no., after given no. which works fine! I even debugged it; but invain;
down here am posting my code; please somebody who can point it out; let me know fast; whats wrong in it...
[code=c]
//Delete a number next to the given number
void afterdelete()
{
struct linklist*temp=N ULL;
int no=0;
temp=(struct linklist*)mallo c(sizeof(struct linklist));
printf("\nEnter the no. whose next no. you want to delete.\n");
scanf("%d",&no) ;
if(no!=NULL && first!=NULL && first->next!=NULL)
{
temp=first;
while(temp->value!=no && temp->next!=NULL)
{
temp=temp->next;
}
if(temp->value==no && temp->next!=NULL)
{
temp->next=temp->next->next;
printf("\nThe edited list is as follows:\n");
display(first);
}
else
{
if(temp->value==no && temp->next==NULL)
{
printf("\nThere is no no. to be deleted after the required no.\n");
}
if(temp->value!=no && temp->next==NULL)
{
printf("\nNo. whose next no. you want to delete is not in the list.\n");
}
}
}
else
{
printf("\nEnter the valid input!\n");
}
}
FOR DELETING A NO., WHICH IS NOT WORKING
//Deleting a number from given list; General deletion
void deletion()
{
int d_no=0;
struct linklist* use=NULL;
use=(struct linklist*)mallo c(sizeof(struct linklist));
printf("\nEnter the number you wish to delete:\n");
scanf("\n%d",&d _no);
if(d_no!=NULL && first!=NULL)
{
use=first;
while(d_no!=use->value && use->next!=NULL)
{
use=use->next;
}
if(d_no==use->value)
{
use=use->next;
printf("\nThe edited list is as follows:\n");
display(first);
}
else
{
printf("\nThe number which you wish to delete is not in the list!\n");
}
}
else
{
printf("\nEnter the valid input.\n");
}
[/code]
}
Waiting for answers.
Comment