All pastes #463115 Raw Edit

Untitled

public text v1 · immutable
#463115 ·published 2007-04-28 19:26 UTC
rendered paste body

// Tokenise
// Return size of infix
int tokenise(char *s, char infix[][MAXLEN])
{
    int len, i, j;
    int count=0;
    len = strlen(s);
    j=0;
    for(i=0; i<len; i++) {
        if (s[i] == '(') {
            strcpy(infix[count++], "(");
            continue;
        }
        if (s[i] == ')') {
            strcpy(infix[count++], ")");
            continue;
        }
        if (strchr("+-/*%^", s[i])) {
            sprintf(infix[count++], "%c", s[i]);
            continue;
        }
        if (isdigit(s[i]) || s[i] == '.') {
            while(isdigit(s[i]) || s[i]=='.') {
                infix[count][j++]=s[i++];
            }
            infix[count][j]='\0';
            count++;
            i--;
            j=0;
        }
    }
    return count;
}