texk/web2c/lib/inputint.c
raw| 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. Public domain. */ |
| 4 | |
| 5 | #include <w2c/config.h> |
| 6 | #include "lib.h" |
| 7 | |
| 8 | /* Read an integer from the file F, reading past the subsequent end of |
| 9 | line. */ |
| 10 | |
| 11 | integer |
| 12 | inputint (FILE *f) |
| 13 | { |
| 14 | char buffer[MAX_INT_LENGTH]; /* Long enough for anything reasonable. */ |
| 15 | |
| 16 | return |
| 17 | fgets (buffer, sizeof (buffer), f) |
| 18 | ? atoi (buffer) |
| 19 | : 0; |
| 20 | } |