/*-------------------------------------------------------------------*/ /* teststack.c (Version 6: Generic ADTs) */ /*-------------------------------------------------------------------*/ #include "stack.h" #include int main(int argc, char *argv[]) { Stack_T oStack1; Stack_T oStack2; double d11 = 1.1; double d22 = 2.2; char str1[] = "one"; char str2[] = "two"; oStack1 = Stack_new(10); Stack_push(oStack1, &d11); Stack_push(oStack1, &d22); while (! Stack_empty(oStack1)) printf("%g\n", *((double*)Stack_pop(oStack1))); Stack_free(oStack1); oStack2 = Stack_new(20); Stack_push(oStack2, str1); Stack_push(oStack2, str2); while (! Stack_empty(oStack2)) printf("%s\n", (char*)Stack_pop(oStack2)); Stack_free(oStack2); return 0; } /* Output: 2.2 1.1 two one */