C++ 将十六进制转换为64位比特集c++;
我想在屏幕上输入一个最多16个十六进制字符的字符串,然后将该字符串转换为一个位集 到目前为止,我已经做到了以下几点C++ 将十六进制转换为64位比特集c++;,c++,C++,我想在屏幕上输入一个最多16个十六进制字符的字符串,然后将该字符串转换为一个位集 到目前为止,我已经做到了以下几点 string tempString; unsigned int tempValue; cout << "enter addr in hex : "; cin >> tempString; istringstream ost(tempString); ost >> hex >> tempValue; bitset<32>
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;
string-tempString;
无符号整数值;
cout>tempString;
istringstream ost(临时字符串);
ost>>十六进制>>温度值;
位集地址(tempValue);
cout hex>>温度值;
wdata=温度值;
猜一猜,您错过了将某些内容更改为64位(可能是位集,也可能是将int
更改为long
)。然而,这是:
string tempString;
unsigned long long tempValue;
cout << "enter addr in hex : ";
cin >> tempString;
istringstream ost(tempString);
ost >> hex >> tempValue;
bitset<64> addr(tempValue);
cout << "addr = " << addr << endl;
[使用VC++和MinGW进行测试,结果相同]只是为了确保,当您对64位进行DDoS时,是否将位集更改为位集一些问题:您应该对tempValue使用uint64_t(只是为了确保您具有正确的大小int)。我假设您已经将addr更新为声明的位集,而不是32。是的,我正在更新该值,谢谢,我应该把它放进去!
string tempString;
unsigned long long tempValue;
cout << "enter addr in hex : ";
cin >> tempString;
istringstream ost(tempString);
ost >> hex >> tempValue;
bitset<64> addr(tempValue);
cout << "addr = " << addr << endl;
enter addr in hex : 0123456789abcdef
addr = 0000000100100011010001010110011110001001101010111100110111101111