- #1
ksepe
- 5
- 0
Set hasDigit to true if the 3-character passCode contains a digit. My attempt is bolded. It is not recognizing number's
Code:
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <ctype.h>
int main(void) {
bool hasDigit = false;
char passCode[50] = "";
int valid = 0;
strcpy(passCode, "abc");
[B] /* Your solution goes here */
int i=0;
for (i=0; i<3; i++) {
hasDigit=isdigit(i);
if(hasDigit) {
hasDigit=true;
}
}[/B]
if (hasDigit) {
printf("Has a digit.\n");
}
else {
printf("Has no digit.\n");
}
return 0;
}