Hi
I have a particular problem where I need to feed two types of inputs into my program, a hex number and a binary number.
Example of input:
Binary
Bi = 1100100
Bi = 0110101
Bi = 0101100
Hexadecimal
3A001341
CA095815
1A596317
How would I be able to distinguish the two?
I usually do:
But obviously it wouldn't work since the loop would be broken at the string "Binary" since it's not in the correct format as the input in scanf. So basically I need some kind of method where the program will know whether the inputs are in binary or hex form, after reading in the headings, or if there's a simpler way.Code:while(scanf("Bi = %d", &binary) == 1) { //blah }
thanks