How do I convert an 8-bit binary string (e.g. \"10010011\") to hexadecimal using C?
How about
char *binary_str = "10010011";
unsigned char hex_num = 0;
for (int i = 0, char *p = binary_str; *p != '\0'; ++p, ++i)
{
if (*p == '1' )
{
hex_num |= (1 << i);
}
}
and now you've got hex_num and you can do what you want with it. Note that you might want to verify the length of the input string or cap the loop at the number of bits in hex_num.