LIFO

Dale Cook cdm at gem-hy.Berkeley.EDU
Sat Nov 3 08:59:06 AEST 1990


In article <111 at dlss2.UUCP>, james at 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.



More information about the Comp.lang.c mailing list