Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!hellgate.utah.edu!fcom.cc.utah.edu!inel.gov!gem-hy!cdm From: cdm@gem-hy.Berkeley.EDU (Dale Cook) Newsgroups: comp.lang.c Subject: Re: LIFO Keywords: with structures Message-ID: <1990Nov2.215906.10168@inel.gov> Date: 2 Nov 90 21:59:06 GMT References: <111@dlss2.UUCP> Sender: news@inel.gov Reply-To: cdm@gem-hy.Berkeley.EDU (Dale Cook) Organization: Idaho National Engineering Laboratory, Idaho Falls, Idaho Lines: 45 In article <111@dlss2.UUCP>, james@dlss2.UUCP (James Cummings) writes: |> |> I have been struggling with what ought to be an easy problem. |> I am trying to build a Last In First Out stack that I can store the |> several structures in. I want to be able to "pop" them back out again |> in reverse order. |> So far, with a structure like: |> struct myst { |> char word1[10]; |> char word2[10]; |> struct myst *next; |> }; |> and some pointers of the same form, I have only managed to retreive |> the last structure on the stack...I seem to be able to go no further. |> |> Could some kind sole, please nudge me in the right direction or ^^^^^^^^^ You want a gentle kick? Or maybe a friendly fish? [couldn't resist...] |> give me a *pointer to a book? Given the structure you have defined, and no information on how you are using it, I can only guess that your problem is that you have defined a stack structure with only one entry. Are you allocating storage for each stack entry as you need it? If not, you need to, or else pick an arbitrary stack maximum and preallocate your structure as an array. ---------------------------------------------------------------------- --- Dale Cook "In order to comprehend the infinite, one need only consider man's capacity for stupidity" --- Edward Abbey ---------------------------------------------------------------------- Lengthy disclaimer follows; press 'n' to skip... ========== long legal disclaimer follows, press n to skip =========== ^L Neither the United States Government or the Idaho National Engineering Laboratory or any of their employees, makes any warranty, whatsoever, implied, or assumes any legal liability or responsibility regarding any information, disclosed, or represents that its use would not infringe privately owned rights. No specific reference constitutes or implies endorsement, recommendation, or favoring by the United States Government or the Idaho National Engineering Laboratory. The views and opinions expressed herein do not necessarily reflect those of the United States Government or the Idaho National Engineering Laboratory, and shall not be used for advertising or product endorsement purposes.