C++ convert string to float
yuibox March 21st, 2008
You can convert a string to a float with atof(3C):It is simple enough but sometimes, after switching languages so often, the syntax gets mixed up and so the functions
Here a little example:
#include <cstdlib>
#include <iostream>
#include <string>
int
main(void)
{
std::string s = “123.456″;
double d = atof(s.c_str());
std::cout << d << std::endl;
return 0;
}
Thanks to eric <3
Stumble it!
Recent Comments