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 res(buffer, buffer + 1024);
Note that there is no conversion other than the unsigned chars in your buffer being converted to chars in the std::string.
unsigned char
buffer
char
std::string
You can use the std::string constructor (number 6 in the link) that uses iterators to copy the buffer into a string:
Note that there is no conversion other than the
unsigned chars in yourbufferbeing converted tochars in thestd::string.