I had some problem with IDE on Firefox so I have copied the code directly over here.
The code is giving the error of SIGSEGV.
node* kappend(node* head, int k)
{
node* ntail;
node* nhead;
node* ptr = head;
int count = 0;
while (ptr != NULL)
{
if (count == k - 1)
{
ntail = ptr;
}
if (count == k)
{
nhead = ptr;
break;
}
ptr = ptr->next;
count++;
}
node* end = head;
while (end->next != NULL)
{
end = end->next;
}
ntail->next=NULL;
end->next = head;
return nhead;
}