Hey I need a little help with unsigned char bit access. I need to test to ensure that “channel” which is an unsigned char (UCHAR) is 6 digits long (i have that) and that the the number enter is infact a binary number (aka 1s or 0s). I at a loss for how to access it. Any help would be great!
void binEnter(void *channel){
int i;
for (i=0; i<6; i++) {
redo:
printf("Enter binary value for Channel %d: ",i);
scanf("%s",(UCHAR *)channel);
if (strlen(channel)!=6) {
printf("Error entry must be six digits!\n");
goto redo;
}
}
}
Make a loop to check each digit.
You could also just use
strtol(3)and check the result inendptrto see if you got a 6-digit number.