Date: Fri, 16 Aug 1996 13:53:14 +0200 (MET DST) From: Mark Habersack Reply-To: grendel AT ananke DOT amu DOT edu DOT pl To: Leath Muller cc: djgpp AT delorie DOT com Subject: Re: bug with gcc??? In-Reply-To: <199608140425.OAA01240@gbrmpa.gov.au> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Wed, 14 Aug 1996, Leath Muller wrote: >I finally got my code to work, and I have to admit I think it's peculiar as >to why... > >The origal code was something like: > > temp = head_of_list; > while (temp->next != NULL) > temp = temp->next; > >This died a horrible death, and yet when I changed the code to the following: >Is this a bug with gcc??? Or what??? :| Nope. It's not a bug. Here's the correct version of you code: temp = head_of_list; while (temp) /* Or, while( temp != NULL ) temp = temp->next The problem was that, when the ->next field was NULL, you were assigning NULL to temp and then tried to reference the NULL pointer. And that, of course, caused you code go to hell. Greetings, Mark /************************************************************/ /** Maybe it was infatuation or the thrill of a chase? **/ /** Maybe you were always beyond my reach and my heart **/ /** was playing safe? ***********/ /** But was that love in your eyes I saw, **/ /** or the reflection of mine? **/ /** I'll never really know for sure, **/ /** You never really gave me time! **/ /** Won't you give me that time? **/ /** "Cindirella Search" **/ /********************************/ Visit my homepage: http://ananke.amu.edu.pl/~grendel