一道笔试题,写程序读出二进制流中指定的几位
为了方便,二进制流放在字符串中,"1122335566"
unsigned int GetBits(string str, unsigned int pos, unsigned int len)
{
} string s("1122335566");
cout < < Hex < < GetBits(s, 12, 8) < < endl;//输出23 我写了很长时间结果都不对,求达人如何写这个函数
为了方便,二进制流放在字符串中,"1122335566"
unsigned int GetBits(string str, unsigned int pos, unsigned int len)
{
} string s("1122335566");
cout < < Hex < < GetBits(s, 12, 8) < < endl;//输出23 我写了很长时间结果都不对,求达人如何写这个函数
取出相应位
再转换回去