modifying items in a linked list?

This is a discussion on modifying items in a linked list? within the C Programming forums, part of the General Programming Boards category; how do I modify a value in a linked list..lets say I have a name and phone number..how I would ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    63

    modifying items in a linked list?

    how do I modify a value in a linked list..lets say I have a name and phone number..how I would modify the phone number??
    Thanks
    A

  2. #2
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Location
    Bangalore, India
    Posts
    345
    Code:
    strcpy(node->phone, new_phone);
    strcpy(node->name,  new_name);

  3. #3
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Are you asking about the actual editing process or going to a specific place in the stack?

  4. #4
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    You can traverse through the list and let a pointer point to the node which you want to change. Then you can change the attributes of that note.

    Code:
    if (list_pointer->key == requested_key)
    {
        list_pointer->item = new_value_for_item;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sorting linked list please help with CODE
    By scarlet00014 in forum C Programming
    Replies: 3
    Last Post: 09-27-2008, 11:24 PM
  2. Replies: 5
    Last Post: 11-04-2006, 05:39 PM
  3. Reverse function for linked list
    By Brigs76 in forum C++ Programming
    Replies: 1
    Last Post: 10-25-2006, 10:01 AM
  4. Problem with linked list ADT and incomplete structure
    By prawntoast in forum C Programming
    Replies: 1
    Last Post: 04-30-2005, 01:29 AM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21