I have string variable (0x7515A0FA). Is it possible to convert in DWORD?
http://www.cplusplus.com/reference/cstdlib/strtol/
DWORD doubleWord = strtol("0x7515A0FA",0, 0);
or as a complete program,
1 2 3 4 5 6 7 8 9 10
|
#include <iostream>
#include <string>
#include <windows.h>
int main()
{
std::string input("0x7515A0FA");
DWORD output = strtol(input.c_str(), 0, 0);
std::cout << std::hex << output << std::endl;
}
|
Last edited on
Alternatively, with streams.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
#include <iostream>
#include <sstream>
#include <string>
#include <Windows.h>
int main(int argc, char* argv)
{
DWORD doubleWord;
std::string dwordHexString = "0x7515A0FA";
std::stringstream dwordStream;
dwordStream << dwordHexString;
dwordStream >> std::hex >> doubleWord;
std::cout << doubleWord;
return 0;
}
|
Last edited on