I'm trying to delete a node on a linked list but after the delete command I tried to display the data inside the node and I could still display the supposedly deleted data. Search is the node im trying to delete
int position=0;
while(admintemp !=NULL)
{
position=position+1;
if(admintemp==search)
{
cout<<"found"<<position;
getch();
break;
}
admintemp = admintemp->next;
}
node *body = new node;
node *admintemp = new node;
if(position>0)
{
admintemp = adminhead;
for (int i= 1;i<position;i++)
{
body = admintemp;
admintemp = admintemp->next;
}
body->next=admintemp->next;
cout<<"deleting";
getch();
delete admintemp;
}