convert string to long long
I'm using VS 2008 to create a C++ DLL (not managed) project and I need convert a char* to a long long type. Is there an easy way to do it?
Thanks in advance :)
Try _atoi64. This takes char* and returns __int64.
The easiest way is to use the std::stringstream (it's also the most typesafe...)
std::stringstream sstr(mystr); __int64 val; sstr >> val;
You may need to target a 64-bit application for this to work.
If you're using boost, lexical_cast is the way to go, in my opinion.
long long ll = boost::lexical_cast<long long>(mystr)