home *** CD-ROM | disk | FTP | other *** search
- /* .subt |Get operation type for desktop calculator */
-
- getop(s,lim)
- char s[];
- int lim;
- {
- int i, c;
-
- while ((c = getch()) == ' ' || c == '\t' || c == '\n')
- ;
- if (c != '.' && (c < '0' || c > '9'))
- return(c);
- s[0] = c;
- for (i = 1; (c = getchar()) >= '0' && c <= '9'; i++)
- if (i < lim)
- s[i] = c;
- if (c == '.') {
- if (i < lim)
- s[i] = c;
- for (i++; (c = getchar()) >= '0' && c <= '9'; i++)
- if (i<lim)
- s[i] = c;
- }
- if (i < lim) {
- ungetch(c);
- s[i] = '\0';
- return(NUMBER);
- }
- else {
- while (c != '\n' && c != EOF)
- c = getchar();
- s[lim-1] = '\0';
- return(TOOBIG);
- }
- }
-
- /* .subt < end of file, file getop.c */
-