Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;:我有一个代表8位的字符串。如何将其转换为字符?_C++ - Fatal编程技术网

C++ C++;:我有一个代表8位的字符串。如何将其转换为字符?

C++ C++;:我有一个代表8位的字符串。如何将其转换为字符?,c++,C++,例如,“11111111”应转换为0B11111/255(在dec中)尝试strtol,基数为2。您具体说是8位,因此: static_cast(std::bitset(str).to_ulong())另一种可能是value=std::bitset(“11111111”)。to_ulong()。这比strtol更专门用于二进制,因此,如果您想要操作某些位,它可以提供优势。例如,如果你想读取一个数字,翻转5位,然后转换为C++风格的解决方案。我正要把它贴出来。甚至写了一个例子,但你已经发布了。无论

例如,“11111111”应转换为0B11111/255(在dec中)

尝试
strtol
,基数为2。

您具体说是8位,因此:


static_cast(std::bitset(str).to_ulong())

另一种可能是
value=std::bitset(“11111111”)。to_ulong()
。这比strtol
更专门用于二进制,因此,如果您想要操作某些位,它可以提供优势。例如,如果你想读取一个数字,翻转5位,然后转换为C++风格的解决方案。我正要把它贴出来。甚至写了一个例子,但你已经发布了。无论如何,我写了这个例子:@Nawaz:Cool page ideone.com!你能直接在浏览器中编译代码吗?@Magnus:是的。去探索吧!事实上有各种各样的语言!