Possible Duplicate:
Converting string of 1s and 0s into binary value
I would like to convert a binary string to an integer string in c++. e.g:
"000000000010" becomes "2"
I have the following constraint: i can not convert this string to an integer type and then convert it again to string because that binary string can be very huge!
I already tried to do it with stringstream, inserting the binary string to it with the flag std::stringstream::binary and then output the content using the std::dec flag, but it doesn’t work
Thank you all in advance.
You could go about it like this:
'1', add 1 to the result (as above)std::reverse)