xref: /original-bsd/usr.bin/learn/objects/getnum.c (revision 730ff649)
1 /*-
2  * Copyright (c) 1988, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.proprietary.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)getnum.c	8.1 (Berkeley) 06/06/93";
10 #endif /* not lint */
11 
12 #include <stdio.h>
13 
14 getnum()
15 {
16 	int c, n;
17 
18 	n = 0;
19 	while ((c=getchar()) >= '0' && c <= '9')
20 		n = n*10 + c - '0';
21 	if (c == EOF)
22 		return(-1);
23 	return(n);
24 }
25