You've got two problems. First, your function as defined takes an array of char
pointers and yet you're passing in a single const char*
. Second, isxdigit
takes a single char
and not an array of char*
. You should change your function to
bool isHex(const char *str)
{
size_t len;
if ( str == NULL ) { // In general, you need to protect your functions from bad arguments.
return false;
}
len = strlen(str);
for (size_t k=0; k<len; k++) {
if ( !isxdigit(str[k]) ) {
return false;
}
}
return true;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…