C++ 字符串转整数:使用 std::stoi 函数
可以使用std::stoi函数将字符串转换为整数。例如:
#include <iostream>
#include <string>
int main() {
std::string str = '123';
int num = std::stoi(str);
std::cout << num << std::endl;
return 0;
}
输出结果为:
123
原文地址: https://www.cveoy.top/t/topic/oZev 著作权归作者所有。请勿转载和采集!