Updating node in linked list

Trying to update a node in a linked list with each node containing a course id, title, prerequisites, and # of credits.

Function is the following:

 
SOLVED THANK YOU!!


After asking the user which course ID they would like to modify from the main, I then call this function, however, nothing happens and the program continues on. What am I doing wrong here? Any advice appreciated!
Last edited on
Look at lines 3 and 5. What do you notice? What is the initial value of curr?
WOW. What a silly mistake. Needs to be NULL. That's embarrassing, thank you!!
Please don't delete the content of your posts after your question is answered. Doing so means future viewers of this thread can gain little benefit from perusing it.

Original code from OP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
void UpdateNode(node* front, string id, string title, vector<string> prereq, string creds)
{
   node *curr = front;

   while(curr != front)
   {
         if (curr->id == id)
         {
               cout << curr->id << "\t" << curr->title << "\t" << curr->prereq << "\t" << curr->creds << endl << endl;

               id = curr->id;
               cout << "Enter updated course title: ";
               cin >> curr->title;
               cout << "Enter updated course prereqs: ";
               cin >> curr->title;
               cout << "Enter updated course credits: ";
               cin >> curr->creds;
         }
         curr = curr->next;
   }
   return;
}
Last edited on
Topic archived. No new replies allowed.