hello !
how can i convert an integer from decimal to hex format in VC++?
any function available ?
Printable View
hello !
how can i convert an integer from decimal to hex format in VC++?
any function available ?
use itoa and use 16 in the last parameter.
A standard way:
[code]
char *tohex(int i, char *s){
sprintf(s,"%x",i);
return s;
}
[code]
And in C++:
Code:#include <sstream>
#include <iomanip>
#include <string>
std::string to_hex(unsigned int n)
{
std::stringstream temp;
temp << std::hex << n;
return temp.str();
}