So I'm trying out this code that was given to me by a friend, and I can't seem to get the data to be inserted to my linked list. retrieveData() was able to retrieve the data from the file but everything goes awry when it's trying to insert the data into the linked list.
I'm not all to familiar with using pointer operations, so can someone come help explain how the insertData() operations are supposed to work? I mean, the algorithm is supposed to simulate a stack operation, but since I can't seem to understand the concept of pointer operations. Well, not yet, I only know the basic ones like *strData = charData[] but not the ones using -> operators...
Well, it's supposed to simulate a stack implementation, like if you had a list of numbers (i.e.: 2,5,9), once you insert all the numbers into the linked list, output should be like this:
9
5
2
But as I've said, I can't understand how the insertData() part of the program works, what with all the lists that was written there and the pointer operations (which I haven't seen, at least from the references that I've read so far). This was the original code. I just added brackets and indention on several parts of the code:
A linked list insert should not need to repeatedly insert new like that; if you're inserting at the end, simply seek to the end of the list (keep going through until the current node->next is NULL, then set that node->next to the node you are inserting.
To be honest, I looked up some sample code and it seems to be much more simple than this. I'm gonna go study it and follow up with questions, if you don't mind.