// Simple stack of integer values with usual push, pop, and check // for emptiness. If an empty stack is popped, you just get 0 back. #include "istack.h" // Testing interface - get values from command line, push, display, pop int main(int argc, char *argv[]) { if (argc < 2) { fprintf(stderr,"Usage: %s n1 n2 ... nk\n", argv[0]); return -1; } StackItem stack; stackInitialize(&stack); for (int i = 1; i < argc; ++i) { push(&stack, atoi(argv[i])); } stackDisplay(&stack); printf("pop returns %d\n", pop(&stack)); printf("pop returns %d\n", pop(&stack)); printf("After 2 pops, the stack is\n"); stackDisplay(&stack); while (!stackIsEmpty(&stack)) { printf("popped %d ...", pop(&stack)); } printf("\n"); printf("Now the stack is\n"); stackDisplay(&stack); }