C++中将string转换成int的两种方式

搜过好几次了,搜过就忘,不如自己记下来

方式一:

string str = "100";
int a = atoi(str.c_str());

方式二:

string str="100";
int a = stoi(str);
发布了377 篇原创文章 · 获赞 344 · 访问量 17万+

猜你喜欢

转载自blog.csdn.net/qq_41895747/article/details/105201134
今日推荐