Link list append doubt


sir it is working fine for test case-1 but showing run error for other test cases.Pl resolve

there is no need to compute the length of the linked list.
you just need to build your list by every time insertAtTail function
and refer this part of the code
void movelast(node*&head)
{
if(head==NULL || head->next==NULL)
{
return;
}
nodesecLast=NULL;
node
last=head;
while (last->next != NULL)
{
secLast = last;
last = last->next;
}
secLast->next=NULL;
last->next=head;
head=last;
}
void kappend(node*&head,int k)
{
int count=0;
for(int i=0;i<k;i++)
{
movelast(head);
}
}
APPROACH:move the last node to the front and second_last node should be made to point to NULL

But ,why is it showing run time error in my code in test cases-2,3,4 and passing first test case

And also tell,where to insert these functions in the code

Pl tell where i need to make corrections in the code

when you dry run your code for this input case
4
1 2 3 4
5
It will not work.
https://ide.codingblocks.com/s/89541 refer this