int转string
1 #include <string> 2 #include <sstream> 3 int n = 0; 4 stringstream ss; 5 string str; 6 ss<<n; 7 ss>>str;
string转int
1 #include <string> 2 std::string str = "123"; 3 int n = atoi(str.c_str());
时间: 2024-11-08 05:45:32
int转string
1 #include <string> 2 #include <sstream> 3 int n = 0; 4 stringstream ss; 5 string str; 6 ss<<n; 7 ss>>str;
string转int
1 #include <string> 2 std::string str = "123"; 3 int n = atoi(str.c_str());