c++ convert string to hex

Use std:stoi as (in C++11 only):

std::string s = "5f0066";
int num = std::stoi(s, 0, 16);

Online demo

Leave a Comment