/* Copyright (C) 1996 by Thomas Glen Smith. All Rights Reserved. */
/* getch APL2 V1.0.0 ***************************************************
* Copied from K&R for Linux apl. *
***********************************************************************/
#define INCLUDES STDIO
#include "includes.h"
#define BUFSIZE 100
char buf[BUFSIZE]; /* buffer for ungetch */
int bufp = 0; /* next free position in buf */
int getch() /* get a (possibly pushed back) character */
{
return(bufp > 0) ? buf[--bufp] : getchar();
}
void ungetch(c) /* push character back on input */
int c;
{
if (bufp >= BUFSIZE)
printf("ungetch: too many characters\n");
else
buf[bufp++] = c;
}