int-> string
//C++11 支持的方法
int ntime = 800;
//tostring的参数可以是int、double、float、long等等
std::string str = std::to_string(ntime);
//""包起来相当于 const char*,不能使用 + 连接
std::string key = "5" + std::string("&&&") + str;
//不能使用C++11时
#include <sstream>
std::stringstream ss;
std::string str = "";
int ntime = 800;
ss << ntime;
ss >> str;
string -> int
//C++11 支持的方法
std::string str = "800";
int ntime = std::stoi(str);
//其他相关函数有stod、stof、stol、stold、stoll,
//返回值分别为double、float、long、long double、long long
//不能使用C++11时
#include <sstream>
std::stringstream ss;
std::string str = "800";
int ntime = 0;
ss << str;
ss >> ntime;