我有一个 int 想存储为二进制字符串表示。如何才能做到这一点?
尝试这个:
#include <bitset>
#include <iostream>
int main()
{
std::bitset<32> x(23456);
std::cout << x << "\n";
// If you don't want a variable just create a temporary.
std::cout << std::bitset<32>(23456) << "\n";
}
关于c++ - 如何在 C++ 中将 int 转换为二进制字符串表示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2890502/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |