Hello,
How would I go about making this program add new Nodes to the list. It seems it is only adding each entry to one node. I put a while loop to re - input data, but the new data just erases the old data. Does anyone know how I could achieve this?
That is because you don't store your data.
You just make a copy of your structure in another instance of the same structure but too bad you can only store one structure. You need to store your structures in a container like vector or list or map (you choose) and when you finish adding new elements show all the data from that container not from the structure like you are doing now cos that structure has just the last data from input.
They are char arrays, but you should think of them as null terminated strings with a maximum length. In this case, number is only 11 bytes long, but you're copying 15 bytes. We call this a buffer overrun; it's a serious error.
You're not inserting the new node into the list correctly. You need to add the new element at the end. You've declared a pointer to the last element, tailPtr, but you don't use it.
Thank You VERY MUCH kbw for strncpy, that helps alot! But im still confused about updating the tail pointer. Sorry for all the questions, but would you mind showing me an example perhaps on how to update the tail pointer, so the data is inserted after the head. Then print it in that order?