Can anyone help me to fix one little problem i am having. When i change the name of an entry, the name changes but the ID number associated with the Entry Deletes. I want the program to leave the ID number alone and print it with the New name. Can anyone help me figure this out?
Think about it for a minute. You have created a linked list with elements in alphabetical order according to the name field. Now you are taking a node and changing the name field. What needs to happen to this structure you just located?
I was going to leave this as an open-ended question, but decided to give you the answer.
1. You need to replace the contents of the name field with the new name.
2. The list element is (probably) no longer in alphabetical order, so it must be removed from the list.
3. The modified element must be re-inserted into the list in the correct location.
Make sure the updated node has the old ID value and the new name. Then you're good.
I have the code to where the program is Changing the name and not deleting it. But how am i supposed to get the ID Number to not delete and to print with the changed name?
1. You need to replace the contents of the name field with the new name.
2. The list element is (probably) no longer in alphabetical order, so it must be removed from the list.
3. The modified element must be re-inserted into the list in the correct location.
Then your question:
But how am i supposed to get the ID Number to not delete and to print with the changed name?
Then look at your code, esp. lines 48-55.
Notice, I never said to delete the node. I said to remove it from and reinsert it into the list. However, you are going to the effort of deleting it and creating a new node. And on top of it, you ask the user for a new ID number.
You need to do 1 of 2 things:
1. (perferred) don't delete the old node. Replace lines 48 - 55 with
2. Save the ID number from pCurrentNode sometime before line 48, get rid of lines 50 - 51, and insert the saved ID number into the new node in line 54.