Ubuntu系统c++中获取输出结果为整型
要将输出结果转换为整型,你可以使用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"转换为整型,并将结果输出到控制台。输出结果为整型数字123。
原文地址: https://www.cveoy.top/t/topic/hImV 著作权归作者所有。请勿转载和采集!