This is a portable implementation for converting a character or an integer to its binary text equivalent.
It makes use of the CHAR_BIT constant (which is defined in the header file climits) to get the number of bits a byte consists of on the implementation where you compile this code on.
Further for simplicity, it makes use of STL: bitset :)
To understand how the program works, I advise you to just compile and run it.
When you run the program, it will ask you to enter a character
(or an integer, in case you're running the integer converter).
After you've pressed the ENTER key, the program will display the corresponding binary value.
I've also supplied some sample output, in case you're not be able to compile the code directly, you could take a look at that first.