You can use the bitset member to_ulong to make the conversion.
Code:#include <iostream> #include <string> #include <vector> #include <bitset> using namespace std; int main() { string pizza("CHEESE"); vector < bitset<8> > b; for (int i=0; i<pizza.length(); i++) b.push_back(pizza[i]); for (int i=0; i<b.size(); i++) cout << b[i] << endl; string pizza_name; for (int i=0; i<b.size(); i++) { char c = b[i].to_ulong(); //cout << (int) c << endl; pizza_name = pizza_name + c; } cout << pizza_name << endl; }



LinkBack URL
About LinkBacks


