Advertisement
Guest User

sheilong

a guest
Aug 27th, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. #include <ctype.h>
  2.  
  3. int getop(char *s)
  4. {
  5.         if (!isdigit(*s) && (*s != '.' && *s != '-'))
  6.                 return *s;       /* not a number */
  7.         if (*s == '-')
  8.                 if (*s++ == '\0')
  9.                         return '-';
  10.         if (isdigit(*s)) /* collect integer part */
  11.                 while (isdigit(*s)) {
  12.                         printf("%c", *s);
  13.                         *s++;
  14.                 }
  15.         if (*s == '.') {   /* collect fractional part */
  16.                 *s++;
  17.                 while (isdigit(*s)) {
  18.                         printf("%c", *s);
  19.                         *s++;
  20.                 }
  21.         }
  22.         return NUMBER;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement