3 ms·
Can someone explain to me why the matchstar function takes its first param as an integer? to me it should be a char. int matchstar(int c, char *regexp, cha
by chollida1 14y ago
Can someone explain to me why the matchstar function takes its first param as an integer?
to me it should be a char.
int matchstar(int c, char *regexp, char *text)
{
do { /* a * matches zero or more instances */
if (matchhere(regexp, text))
return 1;
} while (*text != '\0' && (*text++ == c || c == '.'));
return 0;
}
- deweerdt 14y agoIt doesn't seem to make sense in this context. One hypothesis is that it could have been done out of habit to write safer code: whether char is signed or unsigned is left to the implementation, whereas int is guaranteed to be signed.
- abecedarius 14y agoThe usual reason is to allow c to be EOF, but I don't see why anyone would in this case.