Interesting problem with a Single Linked List #CPP
Hi everyone. I was doing a SLL code that adds an element to the list and i also tried to implement a function that traverses it. The problem is that i get a segmentation fault because the add function is not capable of adding the element. In the add function i use a temporary variable to match it with the head of the list, everything is "ok" at that moment but then when i traverse the list to get to the last node, i assign the temp variable (wich is a pointer to the head) to a new node but it never changes. I've tried making the temporary variable to a double pointer but that just denies me the use of the "->" operator and also the dot. Does anybody has a clue on what is happening here? I would appreciate a lot if anyone could help me. Here's the link to the code: https://code.sololearn.com/cL7hDZI2pI57