The best way to convert binary string to number are the stoXX functions.
http://www.cplusplus.com/reference/string/stoi/[
^]
So:
#include <iostream>
#include <string>
int main()
{
const std::string bitstr = "00001111";
int intval = std::stoi(bitstr, 0, 2);
std::cout << intval << std::endl;
return 0;
}
After that just use your debugger to make sure the input string contains the value you think it should.
If you are using C++11 there is bitset.
http://www.cplusplus.com/reference/bitset/bitset/[
^]
#include <iostream>
#include <string>
#include <bitset>
int main()
{
const std::string bitstr = "00001111";
int intval = static_cast<int>(std::bitset<8>(bitstr).to_ulong());
std::cout << intval << std::endl;
return 0;
}