File: input2int.c

package info (click to toggle)
texlive-bin 2007.dfsg.2-4%2Blenny3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 245,472 kB
  • ctags: 135,653
  • sloc: ansic: 971,350; cpp: 307,149; sh: 53,218; perl: 39,201; makefile: 12,611; python: 6,078; xml: 5,342; asm: 4,245; yacc: 3,108; pascal: 2,483; ruby: 2,089; ada: 1,681; lex: 1,654; objc: 1,357; awk: 1,214; tcl: 973; cs: 879; lisp: 708; sed: 536; java: 172; csh: 47
file content (47 lines) | stat: -rw-r--r-- 1,016 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* input2int.c: read two or three integers from text files.  These
   routines are only used in patgen.  Public domain. */

#include "config.h"

#ifdef INTEGER_IS_INT
#define SCAN2INT "%d %d"
#define SCAN3INT "%d %d %d"
#else
#define SCAN2INT "%ld %ld"
#define SCAN3INT "%ld %ld %ld"
#endif

/* Read two integers from stdin.  */

void
zinput2ints P2C(integer *, a,  integer *, b)
{
  int ch;

  while (scanf (SCAN2INT, a, b) != 2)
    {
      while ((ch = getchar ()) != EOF && ch != '\n');
      if (ch == EOF) return;
      (void) fprintf (stderr, "Please enter two integers.\n");
    }

  while ((ch = getchar ()) != EOF && ch != '\n');
}


/* Read three integers from stdin.  */

void
zinput3ints P3C(integer *, a,  integer *, b,  integer *, c)
{
  int ch;

  while (scanf (SCAN3INT, a, b, c) != 3)
    {
      while ((ch = getchar ()) != EOF && ch != '\n');
      if (ch == EOF) return;
      (void) fprintf (stderr, "Please enter three integers.\n");
    }

  while ((ch = getchar ()) != EOF && ch != '\n');
}