Convert binary to hex in C++