在google play游戏服务上保存游戏所需的数据格式是:https://developers.google.com/games/services/cpp/savedgames上的“数据格式”下指定的:std::vector<uint8_t>
我假设向量表示某种类型的字节数组。对吗?那么如何将std::string转换为std::vector<uint8_t>呢?
发布于 2017-01-19 16:41:27
std::vector有一个专门用于此目的的构造函数:
std::string str;
std::vector<uint8_t> vec(str.begin(), str.end());发布于 2019-03-29 16:23:19
除了DeiDei的答案,如果向量已经构造好了,你可以做以下事情:
std::string str;
std::vector<uint8_t> vec;
...
vec.assign(str.begin(), str.end());https://stackoverflow.com/questions/41737254
复制相似问题