C++ equivalent to C# Encoding.ASCII.GetBytes()

C++ equivalent to C# Encoding.ASCII.GetBytes()

本文关键字:GetBytes ASCII Encoding equivalent to C++      更新时间:2023-10-16

我来自C#,我有一行:

 byte[] key = Encoding.ASCII.GetBytes("myString");

我怎样才能在C++中获得等价物才能获得std::vector<unsigned char>

这应该可以解决问题吗?

unsigned char buffer[mystring.length()];
memcpy(buffer, mystring.data(), mystring.length());