【经验】关于c++11中string类型字符串和整形相互转化的用法

c++11中为我们提供了许多非常方便的函数,可以帮助我们在整形与string类型字符串进行转换 关于Dev-c++如何使用c++11,因为本人是mac系统,使用

c++11中为我们提供了许多非常方便的函数,可以帮助我们在整形与string类型字符串进行转换
关于Dev-c++如何使用c++11,因为本人是mac系统,使用cLion,无法安装Dev,可以在网上搜其他教程实现

整形转字符串(to_string())

to_string函数很好的帮助了我们进行从整形到字符串的转换

#include
using namespace std;
int main(){int a=123;string s;//    用法为
//    string变量 = to_string(整形变量)s= to_string(a);cout<

字符串转整形(stoi)

#include
using namespace std;
int main(){string s="123";int a;//    用法为
//    整形变量=stoi(string类型变量)a=stoi(s);cout<