home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1996 September
/
pcwk_09_96.iso
/
demo
/
wgelectr
/
pk51demo
/
files.2
/
EXAMPLES
/
CSAMPLE
/
CSAMPLE2.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-06-08
|
928b
|
39 lines
/*------------------------------------------------------------------------------
CSAMPLE2.C
Copyright 1995 KEIL Software, Inc.
------------------------------------------------------------------------------*/
#include <stdio.h> /* define I/O functions */
getline (char *line) {
while ((*line++ = getchar()) != '\n');
}
int atoi (char *line) {
bit sign;
int number;
/* skip white space */
for ( ; *line == ' ' || *line == '\n' || *line == '\t'; line++);
/* establish sign */
sign = 1;
if (*line == '+' || *line == '-') sign = (*line++ == '+');
/* compute decimal value */
for (number=0; *line >= '0' && *line <= '9'; line++)
number = (number * 10) + (*line - '0');
return (sign ? number : -number);
}
unsigned int getnumber () {
char line [40];
printf ("Input Number ? ");
getline (line);
return (atoi (line));
}