Number Tokenizer

Float seems to be the only one catching it.

Invalid: '0700?8237169421'
Decimal: '43212312903811273198273'
Float: '3.1?1231231231231'
Invalid: '0x3f?dad'
Invalid: 'hy'
Invalid: '-3'

In decimal(), check the first character separately (it if is a isdigit() or a '-', then proceed to check the following characters as you do now, else return 0).

I changed decimal to this,

int decimal(char *s) {
    char *ptr = s;

    //check if char is not digit or starts with 0
    while (*ptr != '\0')
    {
        if (isdigit(*ptr++))
        {
            return 1;
        }
    }

    return 0;
}

And it is catching it now, however that seems to have made non digit characters be picked up in other ones. This is the new output with my changes. This happened when trying to check for '-' too.

Decimal: '0700?8237169421'
Decimal: '43212312903811273198273'
Float: '3.1?1231231231231'
Decimal: '0x3f?dad'
Invalid: 'hy'
Decimal: '-3'
/r/C_Programming Thread Parent