Thread: Connecting node in singly linked list

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    9

    Connecting node in singly linked list

    how do you connect to separate nodes that is singly

    like if you have a node as headp

    a - link -> b->link

    and connect to a node as temp

    c-link

    so that it will produce

    a-link->b-link->c-link->

    a code in c is much appreciated

    Thanks

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Here's the basic idea, minus error handling.
    Code:
    void addNext ( struct node *list, struct node *newNode ) 
    {
      newNode->next = list->next;
      list->next = newNode;
    }
    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help! Placement of nodes in a Linked List
    By lostmyshadow in forum C Programming
    Replies: 6
    Last Post: 12-17-2007, 01:21 PM
  2. singly linked circular list
    By DarkDot in forum C++ Programming
    Replies: 0
    Last Post: 04-24-2007, 08:55 PM
  3. Replies: 7
    Last Post: 06-16-2006, 09:23 PM
  4. Problems with deleting a node in a singly linked list
    By omishompi in forum C++ Programming
    Replies: 7
    Last Post: 02-23-2006, 06:27 PM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM