I'm flummoxed by how to convert from a binary value to a char in c.
For example, let's say I have 01010110 and want to print the corresponding letter 'V' from that. How do I do this?
Thanks for any help!
I'm flummoxed by how to convert from a binary value to a char in c.
For example, let's say I have 01010110 and want to print the corresponding letter 'V' from that. How do I do this?
Thanks for any help!
Output:
References:
strtol()
strtol()
Did something slightly different:
From the binary, I mathematically calculated the int and simply casted the int into a char.
You can use
strtol()
to parse a number on a string. The last argument (in this case 2) is the radix for the conversion.More information about this and other number parsing functions here.