15,672,517 members
See more:
Hi friends,

thank you
Posted

## Solution 1

This GeeksPlanet article[^] might help.

pablo ramos1 20-Sep-11 14:19pm
Think you André Kraak, but i want a struct contain a table T[10] and a int Top...
Sergey Alexandrovich Kryukov 20-Sep-11 16:57pm
To the point, my 5.
Though, it's not helping OP who is writing gibberish like "T[10]" instead of reading the article.
--SA
André Kraak 20-Sep-11 17:01pm
Thanks, it is appreciated.
Chuck O'Toole 20-Sep-11 19:08pm
Just a comment on the article you pointed to, I don't think that's a very good article. It really doesn't instruct, it only works because of the double dimension of the 'stack' to hold up to 15 characters per entry, uses strcpy, etc. While it works for the author's specific need / example, it will confuse people looking for a simple stack implementation. But, here's 5 for finding it for the OP.

## Solution 2

Back when I was in college, before hardware stacks were invented (and before C was invented), a stack implementation was simply.

Init: declare dimension stack[100] (set the max size of the stack)
integer current = 0;

Push: stack[current++] = data_to_be_saved

Pop: data_restored = stack[--current]

Getting the type right, converting from pseudo-C to real C/C++, and handling cases where the data is an object or string or entire struct are exercises for the student.