#include <iostream> #include <typeinfo> using namespace std; int main() { string s = "Kinght_123"; cout << typeid(s).name() << '\n'; cout << typeid(atoi(s.c_str())).name(); return 0; }
输出:
首先需要引入头文件#include <string>
#include <iostream> #include <typeinfo> #include <string> using namespace std; int main() { string s = "Kinght_123"; cout << typeid(s).name() << '\n'; cout << typeid(stoi(s)).name(); return 0; }
输出:
需要引入头文件#include <string>
#include <iostream> #include <typeinfo> #include <string> using namespace std; int main() { int s = 666; cout << typeid(s).name() << '\n'; cout << typeid(to_string(s)).name(); return 0; }
输出: