构建一个二进制字符串c++
build a binary string c++
如何在c++中构建二进制字符串?
我想要这种格式:
std::string str = signed long (4bytes) "fill out zeros" 0x000 (8bytes) signed long (4bytes)
注意:我不想要可查看的二进制表示,而是字符串中的实际二进制数据
对于您的特定应用程序:
std::string data(12, 0); // construct string of 12 null-bytes
int32_t x, y; // populate
char const * const p = reinterpret_cast<char const *>(&x);
char const * const q = reinterpret_cast<char const *>(&y);
std::copy(p, p + 4, data.begin() );
std::copy(q, q + 4, data.begin() + 8);
char buffer[1024];
// fill up buffer with whatever
char *end = afterLastChar;
std:string s(buffer, afterLastChar);
使用std::vector<uint8_t>,这不是字符串
相关文章:
- 查找"n"二进制字符串中最长公共子字符串的长度
- 如何在C ++中将二进制字符串128位转换为十进制字符串?
- 如何排列二进制字符串以最小化它们之间的距离
- 将二进制字符串/文件内容从 c++ 传递到节点 js
- C++ 将二进制字符串转换为整数或比较 2 个字符串以查找差异数
- 将大型二进制字符串写入二进制文件
- 将浮点数向量转换为十六进制/二进制字符串
- 我如何在二进制字符串中解开KTH集位
- 在 c++ 中将负 int 转换为二进制字符串
- 将二进制字符串转换为十进制
- 在二进制字符串的数字之间留出空间
- 将整数转换为二进制字符串
- 如何将二进制字符串转换为 ASCII 字符串
- C ++检查字符串是否包含字符以及如何将二进制字符串转换为整数
- 在 C/C++ 中将非常大的 int(写为字符串)转换为二进制字符串
- 如何将二进制字符串转换为整数字符串
- 将二进制字符串转换为整数字符串c++
- 构建一个二进制字符串c++
- 这是从二进制字符串转换为十进制值的无效方法吗?
- 将二进制字符串写入二进制文件