Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!usc!orion.cf.uci.edu!uci-ics!bonnie.ics.uci.edu!bvickers From: bvickers@bonnie.ics.uci.edu (Brett J. Vickers) Newsgroups: comp.lang.c Subject: Strange C Problem Keywords: Linked Lists Message-ID: <13812@paris.ics.uci.edu> Date: 9 May 89 21:58:06 GMT Sender: news@paris.ics.uci.edu Reply-To: bvickers@bonnie.ics.uci.edu (Brett J. Vickers) Distribution: na Organization: University of California, Irvine - Dept of ICS Lines: 41 I've come across a very strange problem in one of my programs. I'll list the function that's causing the problems and then discuss what those problems are. Globals: struct msg_node *first_msg, *last_msg; void output_msgs() { struct msg_node { char string[160]; struct msg_node *next; struct msg_node *prev; } *current, *temp; current = first_msg; while (current != NULL) { printf("%s\n",current->string); printf("&"); temp = current; current = current -> next; free (temp); } first_msg = NULL; last_msg = NULL; } Now, this function is supposed to output all the messages that are on the linked list from first to last. But something strange happens. After the function has output its last message, it fails to continue on to the next line (printf("&")). The ampersand isn't output until the next call to output_msgs(). Why is this happening? All help appreciated. -- /*******************************************************************/ /* "Eritis sicut Deus, scientes * bvickers@bonnie.ics.uci.edu */ /* bonum et malum" * --------------------------- */ /*******************************************************************/