mardi 5 janvier 2021

How to convert const uint8_t [] to std::string?

The below code yields an error,

    void emitData(const uint8_t data[], size_t size)
    {
        std::string encodedMessage(data, size);
    }

Error,

no instance of constructor "std::__2::basic_string<_CharT, _Traits, _Allocator>::basic_string [with _CharT=char, _Traits=std::__2::char_traits<char>, _Allocator=std::__2::allocator<char>]" matches the argument list -- argument types are: (const uint8_t *, size_t) 

Aucun commentaire:

Enregistrer un commentaire