Arcanelab Blog
text

How to convert an integer to a hexadecimal string in C++ int number = 42; stringstream…

How to convert an integer to a hexadecimal string in C++

int number = 42;
stringstream ss;
ss << hex << number;
// now ss.str(), which is a string, contains "2a"