In the main function, I've created a head and push front using a function and it works as expected.
However, after using this function to add an information at the end the created node, it doesn't.
The push back data doesn't get attach to the linked list.
Below is my code;
// function pushback using tail
void push_back_t(Node *tail, int data) {
Node *Sn = (Node*)malloc(sizeof(Node)); //creation of the new node called Sn
if (Sn == NULL) {
printf("Erreur");
exit(3);
}
Sn->data = data; //to add the data to the new node
Sn->Next = NULL;
tail->Next = Sn; //make the last Node that tail already point points on the new node
tail = Sn; //make tail to the last and new node
}
What am I doing wrong and how can I fix it?