Want more features on Pastebin? Sign Up, it's FREE!
Guest

nutzz

By: a guest on Jan 11th, 2014  |  syntax: C  |  size: 0.73 KB  |  views: 35  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }
clone this paste RAW Paste Data