Convert uint64_t to std::string

Yakov picture Yakov · Sep 8, 2011 · Viewed 34.7k times · Source

How can I transfer uint64_t value to std::string? I need to construct the std::string containing this value For example something like this:

void genString(uint64_t val)
{
      std::string str;
      //.....some code for str 
      str+=(unsigned int)val;//????
}

Thank you

Answer

dau_sama picture dau_sama · Nov 6, 2014

In C++ 11 you may just use:

std::to_string()

it's defined in header

http://www.cplusplus.com/reference/string/to_string/