motorizedmedia
February 15th, 2008, 01:07 AM
Having a little trouble deleting a pointer, returns only jumbled up numbers...
void deletefn(nametype *head)
{
int option = 0;
nametype *currptr, *deleteptr;
currptr=head;
while(option!=1 && currptr != NULL)
{
cout<<"\nCurrent product is: "<<currptr->description<<endl;
cout<<"Press 1 to delete this product\n "
<<" 0 to continue: ";
cin>>option;
if(option != 1) currptr=currptr->link;}
if(option == 1)
{
currptr = deleteptr;
delete deleteptr;
deleteptr = NULL;
}
else{cout<<"Could not add node to the link."<<endl;}
}//End of deletefn
void deletefn(nametype *head)
{
int option = 0;
nametype *currptr, *deleteptr;
currptr=head;
while(option!=1 && currptr != NULL)
{
cout<<"\nCurrent product is: "<<currptr->description<<endl;
cout<<"Press 1 to delete this product\n "
<<" 0 to continue: ";
cin>>option;
if(option != 1) currptr=currptr->link;}
if(option == 1)
{
currptr = deleteptr;
delete deleteptr;
deleteptr = NULL;
}
else{cout<<"Could not add node to the link."<<endl;}
}//End of deletefn