Hi guys,
i am trying to convert a hex string into binary and store it in a seperate array.
the hex characters must be stored in every nybble instead of every byte. thus reducing the size of the array.
at the moment, i've managed to convert them from chars into hex format and stored them into an array. the next step would be to take the characters, chop them into nybbles and store two of them in every BYTE. at the moment, there is one hex character in every byte.
could anyone help me with that problem?
thanks alot
im using VC++ and windows xp.
my latest code is below
Code:#include <windows.h> #include <string.h> #include <stdio.h> #include <stdlib.h> void main () { char streaminput[300] = "53720caea0e9d080c8280821b775ca286094e9d0402c1bfc50d4fbd700"; //sample string char f; char mybyte; char decode[300], copystring[300]; int i; i = 0; strcpy(copystring, streaminput); while ( i<67 ) /* Walks buffer until NULL */ { f = streaminput[i]; switch( f ) { case '0': mybyte = 0x00; break; case '1': mybyte = 0x01; break; case '2': mybyte = 0x02; break; case '3': mybyte = 0x03; break; case '4': mybyte = 0x04; break; case '5': mybyte = 0x05; break; case '6': mybyte = 0x06; break; case '7': mybyte = 0x07; break; case '8': mybyte = 0x08; break; case '9': mybyte = 0x09; break; case 'a': case 'A': mybyte = 0x0A; break; case 'b': case 'B': mybyte = 0x0B; break; case 'c': case 'C': mybyte = 0x0C; break; case 'd': case 'D': mybyte = 0x0D; break; case 'e': case 'E': mybyte = 0x0E; break; case 'f': case 'F': mybyte = 0x0F; break; strcat (decode, &mybyte); i++; } } }