summaryrefslogtreecommitdiff
path: root/usr.bin/learn/lib/C/getnum.c
blob: 1bb379ee75dd0a205e7b896fa2c37ed6c90e0944 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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);
}