construct a bitset using the string and then convert it to a ulong.
#include <iostream>
#include <string>
#include <bitset>
#include <limits>
using namespace std ;
int main()
{
string str = "00000100" ;
cout << bitset<numeric_limits<unsigned long>::digits>(str).to_ulong()
<< '\n' ;
}
Reputation Points: 1159
Solved Threads: 285
Posting Virtuoso
Offline 1,606 posts
since Dec 2006