(C++) ToInt

January 11, 2018 · View on GitHub

 

 

 

 

 

(C++) ToInt

 

ToInt is a convert code snippet to convert std::string to int.

 

LexicalCast and boost::lexical_cast are more general then ToInt and convert a std::string to any data type.

 


#include <string> ///ToInt converts a std::string to an integer ///From http://www.richelbilderbeek.nl/CppToInt.htm const int ToInt(const std::string& s) {   return std::atoi(s.c_str()); }