I'm writing a simple loop to make sure my input is a valid binary. Ex: I want to throw an error when any number higher than one is user input. I know I need to check against the ASCII numbers. What is going on here? I should not be getting an error when I input binary. Any thoughts?
for (int i=0;i<size;i++)
{
printf("%i is string sub %i\n",int(binary[i]),i);
if (int(binary[i]) != 48 || int(binary[i]) != 49)
{
printf("ERROR NOT A BINARY NUMBER\n");
exit(0);
}
}
input:
0101
Output:
48 is string sub 0
ERROR NOT A BINARY NUMBER