将01字符串转换成数字的办法

利用BITSET+STRING就可以了:
例如
 1 #include <iostream>
 2 #include <bitset>
 3 #include <string>
 4  
 5 using namespace std;
 6  
 7 int main()
 8 {
 9     string str="1101001010";
10     bitset<32> b(str);
11     int n;
12     n=b.to_ulong();
13  
14     cout<<n;
15  
16     return 0;
17 }
原文地址:https://www.cnblogs.com/CKboss/p/3034676.html