home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 9 / FreshFishVol9-CD2.bin / bbs / gnu / unixtex-6.1b-src.lha / unixtex-6.1b / web2c / lib / inputint.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-21  |  1.1 KB  |  60 lines

  1. /* inputint.c: read integers from text files.  These routines are only
  2.    used for debugging and such, so perfect error checking isn't
  3.    necessary.  */
  4.  
  5. #include "config.h"
  6.  
  7.  
  8. /* Read an integer from the file F, reading past the subsequent end of
  9.    line.  */
  10.  
  11. integer
  12. inputint (f)
  13.   FILE *f;
  14. {
  15.   char buffer[50]; /* Long enough for anything reasonable.  */
  16.  
  17.   return
  18.     fgets (buffer, sizeof (buffer), f)
  19.     ? atoi (buffer)
  20.     : 0;
  21. }
  22.  
  23.  
  24. /* Read two integers from stdin.  */
  25.  
  26. void
  27. zinput2ints (a, b)
  28.   integer *a, *b;
  29. {
  30.   int ch;
  31.  
  32.   while (scanf ("%ld %ld", a, b) != 2)
  33.     {
  34.       while ((ch = getchar ()) != EOF && ch != '\n');
  35.       if (ch == EOF) return;
  36.       (void) fprintf (stderr, "Please enter two integers.\n");
  37.     }
  38.  
  39.   while ((ch = getchar ()) != EOF && ch != '\n');
  40. }
  41.  
  42.  
  43. /* Read three integers from stdin.  */
  44.  
  45. void
  46. zinput3ints (a,b,c)
  47.   integer *a, *b, *c;
  48. {
  49.   int ch;
  50.  
  51.   while (scanf ("%ld %ld %ld", a, b, c) != 3)
  52.     {
  53.       while ((ch = getchar ()) != EOF && ch != '\n');
  54.       if (ch == EOF) return;
  55.       (void) fprintf (stderr, "Please enter three integers.\n");
  56.     }
  57.  
  58.   while ((ch = getchar ()) != EOF && ch != '\n');
  59. }
  60.