xref: /csrg-svn/usr.bin/learn/objects/getnum.c (revision 62077)
148274Sbostic /*-
2*62077Sbostic  * Copyright (c) 1988, 1993
3*62077Sbostic  *	The Regents of the University of California.  All rights reserved.
448274Sbostic  *
548274Sbostic  * %sccs.include.proprietary.c%
648274Sbostic  */
748274Sbostic 
834681Sjak #ifndef lint
9*62077Sbostic static char sccsid[] = "@(#)getnum.c	8.1 (Berkeley) 06/06/93";
1048274Sbostic #endif /* not lint */
1134681Sjak 
1234681Sjak #include <stdio.h>
1334681Sjak 
getnum()1434681Sjak getnum()
1534681Sjak {
1634681Sjak 	int c, n;
1734681Sjak 
1834681Sjak 	n = 0;
1934681Sjak 	while ((c=getchar()) >= '0' && c <= '9')
2034681Sjak 		n = n*10 + c - '0';
2134681Sjak 	if (c == EOF)
2234681Sjak 		return(-1);
2334681Sjak 	return(n);
2434681Sjak }
25