Back to index

tetex-bin  3.0
input2int.c
Go to the documentation of this file.
00001 /* input2int.c: read two or three integers from text files.  These
00002    routines are only used in patgen.  Public domain. */
00003 
00004 #include "config.h"
00005 
00006 
00007 /* Read two integers from stdin.  */
00008 
00009 void
00010 zinput2ints P2C(integer *, a,  integer *, b)
00011 {
00012   int ch;
00013 
00014   while (scanf ("%ld %ld", a, b) != 2)
00015     {
00016       while ((ch = getchar ()) != EOF && ch != '\n');
00017       if (ch == EOF) return;
00018       (void) fprintf (stderr, "Please enter two integers.\n");
00019     }
00020 
00021   while ((ch = getchar ()) != EOF && ch != '\n');
00022 }
00023 
00024 
00025 /* Read three integers from stdin.  */
00026 
00027 void
00028 zinput3ints P3C(integer *, a,  integer *, b,  integer *, c)
00029 {
00030   int ch;
00031 
00032   while (scanf ("%ld %ld %ld", a, b, c) != 3)
00033     {
00034       while ((ch = getchar ()) != EOF && ch != '\n');
00035       if (ch == EOF) return;
00036       (void) fprintf (stderr, "Please enter three integers.\n");
00037     }
00038 
00039   while ((ch = getchar ()) != EOF && ch != '\n');
00040 }