c_programming_language/exercices/pointers/4_3_getch.c
2026-02-25 23:10:14 +03:00

15 lines
285 B
C

#include <stdio.h>
#include "4_3_getch.h"
#define BUFSIZE 100
char buf[BUFSIZE];
int bufp = 0;
int getch(void) { return (bufp > 0) ? buf[--bufp] : getchar(); }
void ungetch(int c) {
if (bufp >= BUFSIZE)
printf("ungetch: too many charachters\n");
else
buf[bufp++] = c;
}