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' ;
}
vijayan121
Posting Virtuoso
1,606 posts since Dec 2006
Reputation Points: 1,159
Solved Threads: 287