blob: e41671eb92618192ac76302d196f2b5b27c06561 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include <stdlib.h>
#include <stdio.h>
#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();
}
|