Sunday, March 24, 2013

C++ string to double and vice versa

The C++ 11 way is to use std::stod and std::to_string. Both work in Visual Studio 11.


The STL offers the desired functionality:
std::string  s  = "0.6"
std::wstring ws = "0.7"
double d  = std::stod(s);
double dw = std::stod(ws);


http://stackoverflow.com/questions/1012571/stdstring-to-float-or-double

No comments: