#include #include #include "err.h" #include "getch.h" #define MAXBUFF 100 char buff[MAXBUFF]; static size_t top; void ungetch(char c) { if (top < MAXBUFF) buff[top++] = c; else err("buff: stack overflow"); } char getch(void) { return (top > 0) ? buff[--top] : getchar(); }