/* Example 19.1 : Reversing input sequence The user enters numbers until sentinel 999 The program prints the numbers in the reverse order Author: Peter Brusilovsky */ #include #include #include "StackIntAr.h" #define STACKSIZE 20 void main(){ struct intstack *mystack; int value; mystack = createStack(STACKSIZE); printf("Enter a number, enter 999 to stop: "); scanf("%d",&value); while((value != 999) && (!fullStack(mystack))) { pushStack(mystack, value); printf("Enter another number: "); scanf("%d",&value); } while(!emptyStack(mystack)) { popStack(mystack, &value); printf("%d\n", value); } destroyStack(mystack); }