Reputation: 16029
I'm not fairly familiar in C++ stream API and I want to convert a C code using stream in C++,
char sHex[20] = {0};
int numid = 2;
snprintf( sHex, sizeof(sHex) - 1, "%X", numId );
Upvotes: 2
Views: 351
Reputation: 51483
Take a look at Understanding C++ Streams and Stream Buffers it may help you, like as helped me.
Upvotes: 1
Reputation: 3841
stringstream ss;
ss << uppercase << hex << numId;
string res = ss.str();
Upvotes: 5