int类型转大写十六进制
#include <iomanip>
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
/**
* @description: 将int类型转成大写固定长度16进制,不足填充自定义字符
* @param i 需要转换的16进制
* @param width 转换字符长度,不足填充字符c,否则不生效,默认为2
* @param c 当转换16进制长度小于width用该字符填充,默认为0
* @return 转换的16进制字符串
*/
string dec2hex(int i,size_t width = 2,char c = '0'){
stringstream ioss;
string s_temp;
ioss << setw(width) << setfill(c) << setiosflags(ios::uppercase) << std::hex << i;
ioss >> s_temp;
return s_temp;
}
int main(){
cout << dec2hex(15) << endl;
}