Mail Archives: djgpp/1996/08/16/07:56:53
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
- Raw text -