// Example program
#include <iostream>
#include <string>
int main()
{
std::string a = "7D";
int b = std::stoi(a, nullptr, 16);
std::cout << b << std::endl;
}
when using the old standard stringstream is the way to go:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// Example program
#include <iostream>
#include <string>
#include <sstream>
int main()
{
std::string a = "7D";
std::stringstream ss(a);
int b;
ss >> std::hex >> b;
std::cout << b << std::endl;
}