How to Convert unsigned char* to std::string in C++?

前端 未结 6 1367
予麋鹿
予麋鹿 2020-11-29 02:56

I have unsigned char*, want to convert it to std::string. Can you please tell me the safest way to do this?

6条回答
  •  借酒劲吻你
    2020-11-29 03:18

    BYTE is nothing but typedef unsigned char BYTE;

    You can easily use any of below constructors

    string ( const char * s, size_t n );
    string ( const char * s );
    

提交回复
热议问题