fscanint.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <ctype.h>
3 
4 /*
5  * The fscanint function reads the next int integer from the stream f,
6  * and assigns the value through the second argmument, v, which must be
7  * a pointer. It returns 0 if end of file or an error occurs; otherwise
8  * it returs 1.
9  *
10  * It is faster than fscanf.
11  */
12 
13 int fscanint(FILE * f, int *v)
14 {
15  int val;
16  int c, sign = 1;
17 
18  while (isspace(c = getc(f)));
19  if (c == '-' || c == '+') {
20  if (c == '-')
21  sign = -1;
22  if ((c = getc(f)) == EOF) {
23  ungetc(c, f);
24  return 0;
25  }
26  }
27  if (!isdigit(c)) {
28  ungetc(c, f);
29  return 0;
30  }
31  val = c - '0';
32  while (isdigit(c = getc(f)))
33  val = 10 * val + (c - '0');
34  *v = sign * val;
35  return 1;
36 }
int fscanint(FILE *f, int *v)
Definition: fscanint.c:13
CostFunction c
Definition: LKH.h:304


glkh_solver
Author(s): Francisco Suarez-Ruiz
autogenerated on Mon Jun 10 2019 13:50:26