[英]How to replace QByteArray with std lib?
I want to replace a QByteArray with stdlib.我想用 stdlib 替换QByteArray 。 The QByteArray is used for append various 'struct' and after that, write it on a file.
QByteArray用于 append 各种“结构”,然后将其写入文件。
How can I replace QByteArray ?如何替换QByteArray ? Vector of char?
字符的向量? A buffer Char*?
缓冲区字符*?
What do you recommend me?你给我推荐什么? Thank you
谢谢
I think std::vector<uint8_t>
is suitable.我认为
std::vector<uint8_t>
是合适的。
This is an example of appending elements from v2
to the end of v1
:这是将元素从
v2
附加到v1
末尾的示例:
std::vector<uint8_t> v1 = {1, 2, 3};
std::vector<uint8_t> v2 = {4, 5, 6};
v1.insert(v1.end(), v2.begin(), v2.end());
for (uint8_t val : v1) {
std::cout << (uint32_t)val << ' ';
}
std::cout << '\n';
Output: Output:
1 2 3 4 5 6
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.