Thread: a problem with pointers

  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
    Chappell Hill, Texas
    Posts
    2,332
    If temp never becomes null, then your list must be self referencing and you are going into a loop.
    Mainframe assembler programmer by trade. C coder when I can.

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, 06:38 AM
  5. Problem writing swap using pointers
    By joshdick in forum C++ Programming
    Replies: 1
    Last Post: 02-29-2004, 10:06 PM