String to Int or double

hi does anyone know how to cast a C++ string into an int and a double
thanks
Thanks that was just what i was looking for,
cheers :-)
1
2
3
4
5
#include <boost/lexical_cast.hpp>
string str = "3.14";
try {
    double d = boost::lexical_cast<double>( str );
} catch( boost::bad_lexical_cast const& ) {}


Works for all POD types.

Topic archived. No new replies allowed.