C++ 字符串转16进制

发布时间 2023-03-22 21:13:40作者: iStudyGuy

参考出处:https://blog.csdn.net/FinalCreed/article/details/71037420

string string2hex(const string& str)
{
    string temp;
    stringstream ss;
    string result;
    for (int i = 0; i < str.size(); i++)
    {
        ss << hex << int(str[i]) << " ";
        ss >> temp;
        result += temp;
    }
    
    return result;
}