If the type is already an unsigned int, then you're maybe you should be asking how to display it in hexadecimal format?
1 2 3 4 5 6 7 8
#include <iostream>
#include <iomanip> // for hex, dec
usingnamespace std;
unsignedint value = 1024;
// hex switches to hexadecimal display mode, dec back to decimal
cout << "value = " << hex << value << " / " << dec << value << endl;
Or if you need to write luddite code, use the %x format specifier with the print family of functions.
Actually I wanted to store it in a string.
I get the converting to string by stringstream part.
I can have that in the form of a string, but how can I store it in a variable?