0

How can you convert a decimal to hexadecimal in C++? I've had success with ultoa but that gives you a char (and using (DWORD)Buffer to std::cout just ends in gibberish). Also i need to save the new hexadecimal in a DWORD again.

My Code so far:

//Vars
char Buffer[33];

// Client.dll
DWORD d_clientDll = (DWORD)GetModuleHandleA("client.dll");
_ultoa(d_clientDll, Buffer, 16);
std::cout << Buffer << std::endl;
std::cout << d_clientDll << std::endl;
Shuzuka
  • 66
  • 2
  • 9

1 Answers1

3

Did you try std::hex ?

std::cout << std::hex << d_clientDll << std::endl
Martin Beckett
  • 94,801
  • 28
  • 188
  • 263
  • Surprisingly this suddenly is working (was using a method with std::hex before, that didn't work). How would you save this into a DWORD now? (Offsets::clientDll = std::hex << d_clientDll; Doens't work.) – Shuzuka Apr 30 '17 at 18:26