a problem with pointers

This is a discussion on a problem with pointers within the C Programming forums, part of the General Programming Boards category; I have a doublylinked-list which i already inserted some values, but when i try to make search&update this loop does ...

  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    5

    a problem with pointers

    I have a doublylinked-list which i already inserted some values, but when i try to make search&update this loop does not terminate

    Code:
    if(head!=NULL)
        {
            temp = head;
            while(temp!=NULL)
            {
                if(temp->row==i)
                    temp->data = 100;
                else
                     temp=temp->next;
            }
        }
    although i get 0 when i check tail->next, temp never becomes NULL. How can i solve this problem?

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    If temp never becomes null, then your list must be self referencing and you are going into a loop.
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with file handling (pointers)
    By hmk in forum C Programming
    Replies: 5
    Last Post: 09-19-2008, 10:03 AM
  2. Problem with pointers
    By kotoko in forum C Programming
    Replies: 3
    Last Post: 06-12-2008, 05:17 AM
  3. A problem with pointers
    By vsla in forum C Programming
    Replies: 2
    Last Post: 10-10-2007, 04:14 AM
  4. Returning pointer to array of pointers problem
    By jimzy in forum C Programming
    Replies: 15
    Last Post: 11-11-2006, 05:38 AM
  5. Problem writing swap using pointers
    By joshdick in forum C++ Programming
    Replies: 1
    Last Post: 02-29-2004, 09:06 PM

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