nid help :(

I'm Trying to make a program that converts binary numbers to hexadecimal, and reverse using c++ 2006 yet out of ideas

can someone give me some it doesnt have to be perfect as long as it is working I will revise it anyway

please please

thx in advance
It easiest to store the binary numbers as a c string so you easily iterate through the digits:

1
2
3
4
5
6
7
8
9
10
11
12
int size = 8;
char * bitStr = "10100100"; // 8 bits
char dumStr[4];
char hexStr[size/4];
int i;
for (i = size - 1; i > 0; i -= 4)
{
      // copy 4 bits starting from i and 3 bits to the left into a dumStr
      // match the bit string sequence to its corresponding HEX character
}

 


Hint: look at the member functions for the CString.

Now, what does the algorithm say, starting from the least significant bit, move in steps of 4 bits, and "translate" each arrangement of 4 bits into a HEX character. By translate, you need to use a case statement.

Start up with some code, and I'll help you.
Last edited on
Topic archived. No new replies allowed.