blob: a473190cde976386d36704f77c34af9e14b038a8 (
plain) (
tree)
|
|
#include <stdio.h>
#include <stdlib.h>
#include <error.h>
#include <errno.h>
#include "getch.h"
#define MAXBUFF 100
int gtop;
char buff[MAXBUFF];
char getch(void)
{
return (gtop > 0) ? buff[--gtop] : getchar();
}
void ungetch(char c)
{
if (gtop < MAXBUFF)
buff[gtop++] = c;
else
error(EXIT_FAILURE, ENOBUFS, "getch");
}
|