home *** CD-ROM | disk | FTP | other *** search
-
- #include "mymain.h"
- #include "stack.h"
-
- procedure mymain;
- (* The real program, we will test the stack object *)
- var s : Stack;
-
- begin
-
- (* create a new stack *)
- s := stack_New;
-
- (* push a few numbers onto it *)
- stack_Push(s,1);
- stack_Push(s,2);
- stack_Push(s,3);
-
- (* output the top two elements *)
- writeln('Top = ',stack_Top(s),' NextToTop = ',stack_NextToTop(s));
-
- (* pop a value off and output it *)
- writeln('top was = ',stack_Pop(s));
-
- (* pop off some more values ignoring the result, note that pop does
- nothing to an empty stack
- *)
- stack_Pop(s);
- stack_Pop(s);
- stack_Pop(s);
-
- (* check the stack is now empty *)
- writeln('stack = ',stack_Top(s));
-
- (* dispose of the stack now we have finished with it *)
- stack_Dispose(s);
-
- (* thats all *)
-
- end;
-