home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
-
- #define NUMBER '0'
- #define TOOBIG '9'
-
- int getop(char *s, int lim)
- {
- int i,c;
-
- while ((c = getc(stdin)) == ' ' || c == '\t' ||
- c == '\n')
- ;
-
- if (c != '.' && (c < '0' || c > '9'))
- return(c);
-
- s[0] = c;
- for (i=1; (c = getc(stdin)) >= '0' && c <= '9'; i++)
- if (i < lim)
- s[i] = c;
- if (c == '.')
- { if (i < lim)
- s[i] = c;
- for (i++; (c = getc(stdin)) >= '0' && c <= '9'; i++)
- if (i < lim)
- s[i] = c;
- }
-
- if (i < lim)
- { ungetc(c,stdin);
- s[i] = '\0';
- return(NUMBER);
- }
- else
- { while (c != '\n' && c != EOF)
- c = getc(stdin);
- s[lim-1] = '\0';
- return(TOOBIG);
- }
- }