hi
I want convert Binary String to intger Format in c++.
like "00000100" should give me as "04" or "4"
could anyone suggest me the solution for it.
thanks
Mukesh:)
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' ;
}
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.