Advertisement
Guest User

nutzz

a guest
Jan 11th, 2014
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. int getop(char s[]) {
  2.     if(lp  == lineLength) {
  3.         lineLength = getline(line, MAXLINE);
  4.         lp = 0;
  5.     }
  6.     if(lineLength == 0)
  7.         return EOF;
  8.  
  9.     char c;
  10.     int i;
  11.  
  12.     while((s[0] = c = line[lp++]) == ' ' || c == '\t')
  13.         ;
  14.     s[1] = '\0';
  15.     if(!isdigit(c) && c != '.' && c != '-') {
  16.         return c;
  17.     }
  18.     i = 0;
  19.    
  20.     if(c == '-') {
  21.         if(isdigit(line[lp]) || line[lp] == '.') {
  22.             c = line[lp];
  23.         }
  24.         else {
  25.             return c;
  26.         }
  27.     }
  28.    
  29.     if(isdigit(c)) {
  30.         while(isdigit((s[++i] = c = line[lp++])))
  31.             ;
  32.     }
  33.     if(c == '.') {
  34.          while(isdigit((s[++i] = c = line[lp++])))
  35.             ;
  36.     }
  37.    
  38.     lp--;
  39.     return NUMBER;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement