Results 1 to 3 of 3

Thread: Can anyone tell me why this won't work?

  1. #1

    Thread Starter
    Fanatic Member Gandalf_Grey_'s Avatar
    Join Date
    Oct 2001
    Location
    the 42nd dimension
    Posts
    665

    Can anyone tell me why this won't work?

    Can anyone please tell me why this

    Code:
    void InsertNode(NODE *pNode, NODE *pAfter)
    {              
    
       pNode->pNext = pAfter->pNext;
       pNode->pPrev = pAfter;
      
      if (pAfter->pNext != NULL)
          pAfter->pNext->pPrev = pNode;
      else
          pTail = pNode;
          pAfter->pNext = pNode;
      
    }
    decides it is going to exit the program?

    It is supposed to insert pNode into the linked list after pAfter but it is not working, it just exits every single time. grrrr. Any help would be greatly appreciated

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Step through it with a debugger. The code looks ok. Maybe your linked list gets corrupted by some other means.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    What does your driver do?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width