Kth node from the last element

#include

using namespace std;

class Node {
public:
int DataContainer;
Node *next;

Node(int d)
{
    DataContainer=d;
    next=NULL;
}

};
void Insertion(int d, Node *&head)
{
if (head == NULL)
{
head=new Node(d);
return;
}

Node *n = head;

while (n->next!=NULL)
{
    n=n->next;
}
n->next=new Node(d);

}

Node *input(){
int d;
cin>>d;

Node*head=NULL;

while (d!=-1)
{
    Insertion(d,head);
    cin>>d;
}
return head;

}

void kNode(int k,Node *head)
{
Node *fast=head;
Node *slow=head;
for (int i = 0; i < k; i++)
{
fast=fast->next;
}
while (fast!=NULL)
{
slow=slow->next;
}
cout<<endl;
cout<DataContainer;
}

void print(Node *head)
{
while (head!= NULL)
{
cout<DataContainer<<" ";
head=head->next;
}
}

int main()
{
int k;
int d;
Node *head=input();
cin>>k;
kNode(k,head);
}

https://ide.codingblocks.com/s/469056 is my code

there is Segmentation fault

check now->

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.