Notes on demo 10.1_stack ======================== This code is a modification of the ADT stack demo code presented in lecture 10 of CPSC 223b on February 15, 2007. As presented in class, the stack implementation was not robust, for it failed to check for out-of-memory errors and for attempts to apply pop() or top() to an empty stack. The code here has been made robust. If any of those errors occur, a descriptive message is printed to stderr and the program terminates with EXIT_FAILURE (=1). The error-reporting function fatal() uses some C features that have not yet been discussed in lecture. They are: 1) User-defined functions that take a variable number of arguments (like printf()). 2) The stdarg.h header file and vararg facility (type va_list and function va_start(). 3) The vfprintf() function which acts like fprintf() except that it takes exactly three arguments, and its third argument must be a va_list (which is a variable length list of arguments. 4) The function exit() which terminates execution of the program. It should be called with EXIT_SUCCESS (=0) or EXIT_FAILURE (=1) to indicate a successful or unsuccessful execution. Note that the simple test program in main.c never attempts to pop an empty stack and is unlikely to run out of memory. To exercise the error code (necessary for testing purposes), a different test program is needed.