function to concatenate (join) 2 linked lists

function to concatenate (join) 2 linked lists

Page 1 of 1

1 Replies - 676 Views - Last Post: 09 April 2010 - 08:03 AM Rate Topic: -----

#1 cobain2208  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 04-April 10

function to concatenate (join) 2 linked lists

Posted 09 April 2010 - 07:51 AM

Could someone please explain this function used to join two linked lists?

void concatenate_bothlists()
         {
                node *temp1, *temp2;

                if (start_ptr == NULL || start_ptr2==NULL)
          cout << "cannot concatenate!" << endl;
    
                else
        { 
                        temp1 = start_ptr;
         
                        if (temp1->nxt == NULL)
             { 
                                 temp1->nxt=start_ptr2;
             }

          else
             { 
                                 while (temp1->nxt != NULL)
                { temp2 = temp1;
                  temp1 = temp1->nxt;
                }
                                  temp1->nxt=start_ptr2;
             }
        }
   }


Is This A Good Question/Topic? 0
  • +

Replies To: function to concatenate (join) 2 linked lists

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6063
  • View blog
  • Posts: 23,515
  • Joined: 23-August 08

Re: function to concatenate (join) 2 linked lists

Posted 09 April 2010 - 08:03 AM

DON'T OPEN DUPLICATE TOPICS!!!

Closed.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1