In a previous tip, I showed how to convert a string containing a hexadecimal to int using the sscanf() function. stringstream objects can perform this feat too, in a more object-oriented fashion. In the following program, a string containing a hexadecimal value is converted to int by using an istringstream object. First, the programmer instantiates an istringstream object and initializes it with the hexadecimal string. Then, the stringstream’s setf() member function is called with the ios::hex flag. Finally, the istringstream object writes a decimal value that is equivalent to the hexadecimal value of the original string into the integer n:
#include #include using namespace std;int main(){ string mem_addr =