I'm getting a return value in the form of an 8 bit binary number. For example:
10110010
I need a function that will tell me specifically which bits are high. So for the binary number above, which is decimal 178, I would need a function to take that value and spit back:
bit 7 is high
bit 5 is high
bit 4 is high
bit 1 is high
I see what you did with check_bit but I was using 10110010 as an example. I need this to work for any binary value. In main you have specifically put 7,5,4,1 into the array. How can I put each bit into the array for any binary value I receive?
Yeah, but there's no point thinking about it unless the Op can say what input and output he needs.
I'm sure he doesn't want a function that writes text to stdout, that'd be silly; or maybe he does. He's managed to say he wants to pass in any integral value after someone posted a solution, ... see what I mean?
I see what you did with check_bit but I was using 10110010 as an example. I need this to work for any binary value.
It works for any value that meets the constraints in the OP.
In main you have specifically put 7,5,4,1 into the array. How can I put each bit into the array for any binary value I receive?
The bits in the array are the bits to check. Change what's in the array to change which bits you're checking (or don't even use the array.) The code in main is just demonstration.