#include#include int main() { TString str = "3.14159"; float f = str.Atof(); // converting string to float std::cout << "float value: " << f << std::endl; return 0; }
#includeIn this example, a string with the value "pi = 3.14159265359" is declared. The Atof method is used to convert a substring "3.14159" extracted from this larger string. The resulting float value is then printed to the console. The package/library used in both examples is ROOT (R and OO programming toolkit).#include int main() { TString str = "pi = 3.14159265359"; TString strPi = str(6, 13); // extracting "3.14159" from the string float f = strPi.Atof(); // converting extracted string to float std::cout << "float value: " << f << std::endl; return 0; }