[Solved] c++ can not get value from map


Your void Write(const std::string& inString) function of OutputMemoryStream should not store additional byte of buffer for null terminator because std::string will not contain null terminator but if you use c_str(), a null terminator will be included in the return from this method. Don’t get confused with the internal structure of the memory. std::string stores the length of the string in its member variable so there is no need of null terminator. The function should be as shown below.

void Write(const std::string& inString)
{
    size_t elementCount = inString.size();
    Write(elementCount);
    Write(inString.data(), elementCount * sizeof(char));
}

2

solved c++ can not get value from map