0
[Solved, but I still have a question] C++ Question re assigning int to another var as hex
I understand how to convert an int (or multiple var) to hex using std::hex during output (cout) int x = 123; cout << hex << x; but how would one instead assign the hex value to a different variable, like y? Solved: int x = 123; stringstream ss; ss << hex << x; string y = ss.str(); Out of curiosity, if one wanted to convert multiple int is there a strategy aside from repaying this many times? Perhaps a loop, but in that case how would one keep reassigning the in and out variable names?
2 Réponses
+ 2
you need use loop and probably a array of stringstreams
0
Giannis
I'm thinking you could be right. If going straight to cout one sstream might do but to place each int to a different hex var is likely a different story.
Still you think there would be a way to do it with large amounts of integers... maybe looping into an array? Or vectors? (I know *nothing* about vectors yet except they exist 🙄).