#include #include #include using std::cout; using std::string; using std::to_string; using std::stoi; using std::stod; int main() { cout.precision(17); string str1 = "1234.56789"; int x = stoi(str1);// x = 1234 double xd = stod(str1); // xd = 1234.56789 string i_to_s = to_string(x); // i_to_s = "1234" string d_to_s = to_string(xd); // d_to_s = "1234.56789" string sub1 = str1.substr(5);// sub1 = "56789" string sub2 = str1.substr(5,3);// sub2 = "567" string sub3 = sub1 + sub2;// sub3 = "56789567" const char *ch = str1.c_str(); // ch = "1234.56789" cout << "str: " << str1 << "\t type: " << typeid(str1).name() << "\n"; cout << "str to int: " << x << "\t type: " << typeid(x).name() << "\n"; cout << "str to double: " << xd << "\t type: " << typeid(xd).name() << "\n"; cout << "substr one parameter: " << sub1 << "\t type: " << typeid(sub1).name() << "\n"; cout << "substr two parameter: " << sub2 << "\t type: " << typeid(sub2).name() << "\n"; cout << "string + operation: " << sub3 << "\t type: " << typeid(sub3).name() << "\n"; cout << "str to char array: " << ch << "\t type: " << typeid(ch).name() << "\n"; }