我正在尝试从 16 位二进制字符串中提取 4 位,即从一个单词中剔除 谁能告诉我这个程序有什么问题?
#include <sstream>
#include <iomanip>
#include <math.h>
#include<iostream>
using namespace std;
int main()
{
std::string aBinaryIPAddress = "1100110011001100";
std::string digit0 = aBinaryIPAddress & 0x0f;
cout << "digit0 : " << digit0 << endl;
std::string digit1 = (aBinaryIPAddress >> 4) 0x0f;
cout << "digit1 : " << digit1 << endl;
std::string digit2 = (aBinaryIPAddress >> 8) 0x0f;
cout << "digit2 : " << digit2 << endl;
std::string digit3 = (aBinaryIPAddress >> 12) 0x0f;
cout << "digit3 : " << digit3 << endl;
return 0;
}
我收到以下错误:
changes.cpp: In function `int main()':
changes.cpp:117: error: invalid operands of types `char*' and `int' to binary `
operator>>'
changes.cpp:117: error: parse error before numeric constant