[英]How can I convert a string into a byte array in c++?
How can I convert this C# code to C++? 如何将此C#代码转换为C ++?
string map = "maps\guardian";
byte[] mapName = Encoding.ASCII.GetBytes(map);
Use std::string
like this 像这样使用std::string
std::string myString("Hello World!");
const char* myConstArray = myString.c_str();
char myNonConstArray[100];
strcpy(myNonConstArray, myString.c_str());
both const and non-const versions there. 那里的const和非const版本。
Would not this suffice?: 这不够吗?:
std::string map = "maps\guardian";
char* asciimap = map.c_str();
In C++ there is no byte
type. 在C ++中,没有byte
类型。 You only have char
. 您只有char
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.