diff options
author | Ian Darwin <ian@cvs.openbsd.org> | 1998-09-28 16:01:29 +0000 |
---|---|---|
committer | Ian Darwin <ian@cvs.openbsd.org> | 1998-09-28 16:01:29 +0000 |
commit | e9be7faad5fbf61edcad3700142615e315e407bc (patch) | |
tree | 5f3febafdfca4e38b83cbc129c87aefdece9ae70 /usr.bin/learn/lib/C/getnum.c | |
parent | 0436a5b6c19a613da918536b89a49cbcb38a2e4e (diff) |
import BTL learn(1) lessons/C
Diffstat (limited to 'usr.bin/learn/lib/C/getnum.c')
-rw-r--r-- | usr.bin/learn/lib/C/getnum.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/usr.bin/learn/lib/C/getnum.c b/usr.bin/learn/lib/C/getnum.c new file mode 100644 index 00000000000..1bb379ee75d --- /dev/null +++ b/usr.bin/learn/lib/C/getnum.c @@ -0,0 +1,13 @@ +#include <stdio.h> + +getnum() +{ + int c, n; + + n = 0; + while ((c=getchar()) >= '0' && c <= '9') + n = n*10 + c - '0'; + if (c == EOF) + return(-1); + return(n); +} |