A friend of mine sent me his program. He uses "stod" function to convert string to double. Is there any other possibility to do such thing?
My complier shows error "stod was not declared in this scope"
I've included #include <string> #include <cstdlib> but nothing has changed.
My complier doesn't use C++11 features. By the way, that program were prepared as a school project, without purpose of using C++11.
std::atof() is a quick option handed over from C language, you have to include <cstdlib> to use it.
Otherwise you can use std::stringstream to handle it.
#include<sstream>
std::string value="14.5";
std::stringstream ss;
ss<< value;
double d=0.0;
ss>>d;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With