What is the error in this code?

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;

}

Hi Vansh,
refer this https://ide.codingblocks.com/s/617986

Thank you Sir for the guidance , I was able to find my mistake in the code.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.