am trying to figure out how to insert a new number in a linked list after a specified number...i am failing to figure out how to fix in the number in the list...here is the partial code..any help is appreciated

void insert(detailsPtr& head)
{
	
	detailsPtr prev, current,tmp;

	int num,curr_num;

	cout<<"Enter the number which you want your new number to follow:";

	cin >> curr_num;

	cout<<"Enter the number to insert: ";

	cin >> num;

	cout<< endl;
	
	prev=head;

	current=prev->link;

	while(prev->link!=NULL)
    {
       
        if(prev->prod_id==curr_num)
        {
           
			tmp= new details;

			tmp->prod_id=num;

			tmp->link=current;

			prev->link=tmp;
		}

		if(prev->link==NULL)
		{
		
			cout<<"The number you entered cannot be found"<<endl;

		}
	}

}
struct details
{

	int prod_id;

	details *link;
};
	
typedef details* detailsPtr;

uhuh...that worked...got tangled up and didnt even think of that..thanx

This question has already been answered. Start a new discussion instead.