read through one character at a time. the ones column will be added to the other column times 16. ie:
54 = 4 + (5 * 16)
more technically
54 = (4 * 16^0) + (5 * 16^1)
by now you should have a hex number you want to test for bits. 1 looks like this:
if you want to test the ones digit here you want to mask away all the unnecessary digits. 0x54 looks like this:
to test a bit you want to logical and it. in c, it's this sign: &
Code:
0101 0100
&
0000 0001
=
0000 0000
and returns a one only when both are ones.
you want to set up this kind of loop:
Code:
int x = 0x57;
for (int i=0x80;i;i>>=1)
if (x & i)
printf("1");
else
printf("0");
the i>>=1 shifts i's bit once to the right.
i starts off as
Code:
1000 0000
0100 0000
0010 0000
0001 0000
0000 1000
0000 0100
0000 0010
0000 0001
every time you test the other number to see if the bit is set, then do something accordingly.