#include "string"
#include "iostream"
int main()
{
int a = 12;
std::string str = std::to_string(a); //int 转string
int b;
b = atoi(str.c_str());
std::cout<<"b="<<b<<std::endl; //string 转 int,输出b=12
}
【C++笔记】std::string与int相互转换
最新推荐文章于 2025-04-11 21:45:14 发布