/*------------------------------------------------------------------*/ /* teststackbad.c */ /* Author: Bob Dondero */ /* A Stack ADT client that can access the ADT's data structure */ /*------------------------------------------------------------------*/ #include "stackbad.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_pop(psStack1)); /* Could 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_pop(psStack2)); /* Could access the fields of *psStack2 here. */ Stack_free(psStack2); return 0; } /* Output: 3.3 2.2 1.1 6.6 5.5 4.4 */