L
LL
#include <stdio.h>
#define ISDIGIT(x) \
switch(x) { \
case '0': \
case '1': \
case '2': \
case '3': \
case '4': \
case '5': \
case '6': \
case '7': \
case '8': \
case '9': \
return true; \
default: \
return false; \
}
bool isdigit(char x) {
ISDIGIT(x)
}
int main() {
char a;
for (;
{
scanf("%c", &a);
if (a=='q') break;
if (isdigit(a))
printf("Is digit\n");
else
printf("Is not digit\n");
}
}
/*
Output:
a
Is not digit.
Is not digit.
1
Is digit
Is not digit
What's causing every second line to print Is not digit?
*/
#define ISDIGIT(x) \
switch(x) { \
case '0': \
case '1': \
case '2': \
case '3': \
case '4': \
case '5': \
case '6': \
case '7': \
case '8': \
case '9': \
return true; \
default: \
return false; \
}
bool isdigit(char x) {
ISDIGIT(x)
}
int main() {
char a;
for (;
scanf("%c", &a);
if (a=='q') break;
if (isdigit(a))
printf("Is digit\n");
else
printf("Is not digit\n");
}
}
/*
Output:
a
Is not digit.
Is not digit.
1
Is digit
Is not digit
What's causing every second line to print Is not digit?
*/