/*--------------------------------------------------------------------*/ /* teststack.c (Version 1) */ /* Author: Bob Dondero */ /*--------------------------------------------------------------------*/ #include "stack.h" #include int main(void) /* Test the Stack ADT. Return 0. */ { struct Stack *psStack1; struct Stack *psStack2; psStack1 = Stack_new(); Stack_push(psStack1, 1.1); Stack_push(psStack1, 2.2); Stack_push(psStack1, 3.3); while (! Stack_isEmpty(psStack1)) { printf("%g\n", Stack_top(psStack1)); Stack_pop(psStack1); } /********************************************/ /* Can access the fields of *psStack1 here. */ /********************************************/ Stack_free(psStack1); psStack2 = Stack_new(); Stack_push(psStack2, 4.4); Stack_push(psStack2, 5.5); Stack_push(psStack2, 6.6); while (! Stack_isEmpty(psStack2)) { printf("%g\n", Stack_top(psStack2)); Stack_pop(psStack2); } /********************************************/ /* Can access the fields of *psStack2 here. */ /********************************************/ Stack_free(psStack2); return 0; } /* Output: 3.3 2.2 1.1 6.6 5.5 4.4 */