A character array of type char is entered manually. It is necessary then to make the check of each element equal to 1 or 0, if at least one of the array elements is not 0 or 1, then output Number is wrong.
My code looks like this, I can not understand what the error is:
#include <stdio.h> int main() { char str[10] = {0}; scanf("%s", str); for(int i = 0; i < 6; i++) { if(str[i] != 0 && str[i] != 1) printf("Number is wrong"); } system("pause"); return(0); }
1and0? Or'1'and'0'? These are completely different things. - AnT 4:44 pm