Thread: Need help Debugging (ADT)

  1. #16
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    So how about you start checking your values before you start trying to use them?
    Code:
    void insertBeforeFirst(ListRef L, int data){
      NodeRef temp= newNode(data);
      if(L== NULL){
        printf("Queue Error: called insertBeforeFirst() on NULL ListRef\n");
        exit(1);
      }
      if(isEmpty(L)){ L->head= L->tail= temp; }
      else{
        temp->next = L->head;
        L->head->prev= temp;
        L->head= temp;
      }
      L->length++;
    }
    Check to see that ->head exits before you start trying to access its members. Never assume a pointer points somewhere valid. It's obvious it doesn't, since your debugger is telling you it doesn't.


    Quzah.
    Hope is the first step on the road to disappointment.

  2. #17
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    If this is a legitimate debugging session, then this would appear to be the first time you've inserted anything in the list -- yet the isEmpty test comes out false. Is this actually the first thing you are inserting in the list?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help debugging this
    By CoreLink in forum C Programming
    Replies: 17
    Last Post: 04-25-2010, 08:19 PM
  2. Debugging help
    By kpridd in forum C++ Programming
    Replies: 3
    Last Post: 12-06-2009, 12:04 PM
  3. debugging in VC++
    By cwmccart in forum C++ Programming
    Replies: 1
    Last Post: 07-11-2008, 01:32 AM
  4. debugging
    By St0rM-MaN in forum Tech Board
    Replies: 13
    Last Post: 07-06-2007, 02:03 PM
  5. VC++ Debugging
    By neandrake in forum C++ Programming
    Replies: 5
    Last Post: 12-02-2003, 07:31 PM