I\'m trying to convert an incoming sting of 1s and 0s from stdin into their respective binary values (where a string such as \"11110111\" would be converted to 0xF7). This s
You can use Boost Dynamic Bitset:
boost::dynamic_bitset<> x(std::string("01011")); std::cout << x << ":" << x.to_ulong() << std::endl;