How can I convert hexadecimal numbers to binary in C++? -


I am taking a starting C ++ class, and want to convert letters between hex representation and binary. I can print using hex numbers:

 for  (char c = 'a'; c & lt; = 'z'; c ++) {cout & lt; & Lt; Hex & lt; & Lt; (Integer) c; }  

But I can not do this for binary. There is no std :: bin that I can use to convert a decimal number to binary.

similarly:

 for  (char c = 'a '; C & lt; =' z '; c ++) {std :: bitset & lt; Size (character) * CHAR_BIT & gt; Binary (c); // sizeof () returns bytes, not bits! Std :: cout & lt; & Lt; "Letter:" & lt; & Lt; C & lt; & Lt; "\ T"; Std :: cout & lt; & Lt; "Hex:" & lt; & Lt; Std :: hex & lt; & Lt; (Int) C & lt; & Lt; "\ T"; Std :: cout & lt; & Lt; "Binary:" & lt; & Lt; Binary & lt; & Lt; Std :: endl; }  

Comments