Problem with string conversion
May 22, 2014 at 12:31pm UTC
Hi, I have this code that wil hash the return value of harddrive serial number but I'm having some problem.
1 2 3 4 5 6 7 8 9
DWORD serialNumber = { 0 };
std::string buffer;
GetVolumeInformation(("C:\\" ), NULL, NULL, &serialNumber, NULL, NULL, NULL, NULL);
std::hash<_STD string> hs;
buffer = hs(std::to_string((_ULONGLONG)serialNumber));
std::cout << buffer << std::endl;
std::cout << hs(std::to_string((_ULONGLONG)serialNumber)) << std::endl;
As you can see I have 2 cout, the first one was printing a sysmbol like a small T and the second one was working fine. But the one I need is the first one but I don't know what is wrong.
May 22, 2014 at 12:48pm UTC
hash function returns value of std::size_t, not string. You can assign number to string bur you will gen unexpected results.
May 22, 2014 at 12:57pm UTC
how can I convert it to string?
May 22, 2014 at 12:59pm UTC
std::to_string
is created to convert values to string
Last edited on May 22, 2014 at 1:00pm UTC
Topic archived. No new replies allowed.