简体   繁体   English

如何将LPBYTE转换为字符串

[英]How to convert LPBYTE to string

LPBYTE buffer = (LPBYTE)calloc(1024, sizeof(char));
std::string res;

I want something like: 我想要类似的东西:

res = buffer;

You can use the std::string constructor (number 6 in the link) that uses iterators to copy the buffer into a string: 您可以使用std :: string构造函数(链接中的数字6),该构造函数使用迭代器将缓冲区复制到字符串中:

std::string res(buffer, buffer + 1024);

Note that there is no conversion other than the unsigned char s in your buffer being converted to char s in the std::string . 请注意,除了将bufferunsigned char转换为std::string中的char之外,没有其他转换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM