Friday, June 21, 2019

C++: convert an integer to a hex string


#include <iostream>
#include <sstream>
#include <iomanip>

long i = 127;

std::ostringstream oss;


oss << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(8) << i;


std::string result = oss.str();


No comments:

 
Get This <