6
std::stringstream ss; ss << "0.1234"; float f; ss >> f;
#include <iostream> #include <sstream> using namespace std; int main() { string str = "0.1234"; float f; f = atof(str.c_str()); cout << f << endl; stringstream ss; ss << "0.12345"; ss >> f; cout << f << endl; return 0; }