题解 | #将字符串转化为整数#
将字符串转化为整数
http://www.nowcoder.com/practice/44d8c152c38f43a1b10e168018dcc13f
使用STL中的stringstream实现转换。
class Solution {
public:
int atoi(const char *str) {
int val{};
stringstream s_stream{};
s_stream<<str;
s_stream>>val;
return val;
}
};