Not much of a C++ developer and the multiple ways to handle strings always confuses me.
int Mine_SSL_Read(SSL* ssl, void* buf, int size)
{
int length = Real_SSL_Read(ssl, buf, size);
CString msg = ???
}
However I need to write a hook for SSL_Read function (OpenSSL) and that requires some C++ code. I need to convert buf which is of type void* and has a length of “length” into a CString so it can be parsed by other code.
Assuming the
void*is simply one-byte (ASCIIor similar) characters:If you know it is
NULLterminated, you can simply cast it:If it is not
NULLterminated, or you don’t know that fact, then you have to copy it byte by byte (I don’t believeCStringhas anassignfunction similar to std::string).