The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 06-30-2009
mgessner mgessner is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 50
This is a problem:

Code:
Obj *pp, *head;
...
pp = head;

/* other stuff involving pp, which is wrong because pp was set to an unknown value. */

head was never initialized. You must always initialize a pointer before you use it. It must either be NULL (in which case you don't dereference it) or you must point it to something.

I think what you need to do is draw a picture (a box, perhaps) and divide it up into pieces (as many as you have objects) and then draw the arrows that represent the pointers.

Your code below doesn't work because it's correct; it works because you are unlucky.