Handling of conversions from and to hex

后端 未结 3 1863

I want to build a function to easily convert a string containing hex code (eg. \"0ae34e\") into a string containing the equivalent ascii values and vice versa. Do I have to cut

3条回答
  •  心在旅途
    2021-01-24 03:51

    If you want to use a more c++ native way, you can say

    std::string str = "0x00f34" // for example
    
    stringstream ss(str);
    
    ss << hex;
    
    int n;
    
    ss >> n;
    

提交回复
热议问题