Insertion problem

void makeinfront(node*&head,int k)
{
node* temp=head;
while(temp!=NULL)
{
temp=temp->next;
}
temp->next=head;
int j=1;
node*temp2=head;
while(j<5-k)
{
temp2=temp2->next;
j++;
}
temp2->next=NULL;
return;
}

i am unable to made out the mistake i am doing here

Hi @shubhamssj5.ss

What exactly are you trying to perform with this code. Also copy it in cb ide and give the link here. Also give the link of the question.