Your issue lies in the pop()
function. It should look like
void pop(stack *stk)
{
if (stk->stksize==0)
{
printf("nothing to pop");
return;
}
node *temp=stk->head->next;
free(stk->head);
stk->head = temp;
stk->stksize--;
}
And don't forget to handle the 0 in your partition()
function.