When I compile your code with clang-cl
, it reports the following error on the line with the if
statement:
error : subscript of pointer to function type 'int (int)'
As to why you see the "binary bitwise operator" error message - the comment provided by Eric Postpischil may well explain that (isdigit
is not implemented as a macro on the system I am using, BTW).
This and other errors can be resolved by simply 'moving' one opening bracket. The code below shows your line (with spaces added for alignment) with a corrected version (I've also made the assumption that you actually want to test str[i]
for being a digit, rather than i
itself):
int main()
{
char str[] = "a-bc-de-fg=12=345";
for (int i = 0; i < strlen(str); i++) {
// if ( ( !isalpha(str[i]) ) && ((!isdigit [i] ) ) ) { // Original code
if ( ( !isalpha(str[i]) ) && ( !isdigit(str[i]) ) ) { // Corrected code
printf("something");
}
}
return 0;
}
I hope this helps you clear up your problems!