(C++) ReadDoubleFromFile
February 24, 2017 · View on GitHub
(C++) ReadDoubleFromFile
File I/O code snippets to read the first line of a file and convert it to a double.
///ReadDoubleFromFile reads the first line of a file ///and converts it to a double. ///From http://www.richelbilderbeek.nl/CppReadDoubleFromFile.htm double ReadDoubleFromFile(const std::string& fileName) { const std::vector<std::string> v = FileToVector(fileName); assert(v.empty()==false); const double d = std::atof(v[0].c_str()); return d; }