home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / tools / formatte / clist / getch.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-01-21  |  372 b   |  24 lines

  1. /* .subt | Get and save character routines for desktop calculator */
  2.  
  3. #define BUFSIZE  100
  4.  
  5. char buf[BUFSIZE];
  6. int  bufp = 0;
  7.  
  8. getch()
  9. {
  10.   return((bufp > 0) ? buf[--bufp] : getchar());
  11. }
  12.  
  13. ungetch(c)
  14. int c;
  15. {
  16.   if (bufp > BUFSIZE)
  17.      printf("ungetch: too many characters\n");
  18.   else
  19.     buf[bufp++] = c
  20. }
  21.  
  22. /* .subt < end of file, file getch.c */
  23.  
  24.