Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ctype.h>
- int getop(char *s)
- {
- if (!isdigit(*s) && (*s != '.' && *s != '-'))
- return *s; /* not a number */
- if (*s == '-')
- if (*s++ == '\0')
- return '-';
- if (isdigit(*s)) /* collect integer part */
- while (isdigit(*s)) {
- printf("%c", *s);
- *s++;
- }
- if (*s == '.') { /* collect fractional part */
- *s++;
- while (isdigit(*s)) {
- printf("%c", *s);
- *s++;
- }
- }
- return NUMBER;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement