string a = “1234”;

可以使用strstream字符流类。

int strtoint(string a){
    strstream ss;
    int  res;
    ss << a;
    ss >> res;
    return res;
}

string tostring(int a){
    strstream ss;
    string res;
    ss << a;
    ss >> res;
    return res;
}

  

c++11有std::to_string() 转为字符串的和字符串转整数stoi(str)、字符串转double类型stod(str)。

相关文章:

  • 2022-12-23
  • 2021-12-20
  • 2022-12-23
  • 2022-12-23
  • 2021-07-17
  • 2021-12-20
  • 2022-02-13
  • 2022-12-23
猜你喜欢
  • 2022-02-08
  • 2022-02-20
  • 2022-12-23
  • 2021-05-25
  • 2022-01-29
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案