我想在屏幕上输入最多 16 个十六进制字符的字符串,然后将该字符串转换为 bitset<64>
到目前为止,我已经管理了以下
string tempString;
unsigned int tempValue;
cout << "enter addr in hex : ";
cin >> tempString;
istringstream ost(tempString);
ost >> hex >> tempValue;
bitset<32> addr(tempValue);
cout << "addr = " << addr << endl;
效果很好,但是当我重复 64 位时它失败了。玩弄它似乎只对前 32 位失败!
bitset<64> wdata = 0;
if (rdnwr[0] == 0)
{
cout << "enter wdata in hex : ";
cin >> tempString;
istringstream ost1(tempString);
ost1 >> hex >> tempValue;
wdata = tempValue;
cout << "wdata = " << wdata << endl;
}
这与 istringstream 的最大大小有关吗?或者也许是我分配 wdata 的不同方式?
谢谢。