c++string转int
时间: 2023-06-02 15:04:24 浏览: 97
可以使用 stoi 函数将 C++ 中的 string 类型转化为 int 类型。例如:
```c++
std::string str = "123";
int num = std::stoi(str);
```
相关问题
c++ string 转 int
可以使用 `std::stoi()` 函数将 `std::string` 类型转换为 `int` 类型。例如:
```c++
#include <iostream>
#include <string>
int main() {
std::string str = "123";
int num = std::stoi(str);
std::cout << num << std::endl;
return 0;
}
```
输出:
```
123
```
c++ string转int
你可以使用 std::stoi() 函数将 C++ 中的字符串转换为整数。例如:
```cpp
#include <string>
#include <iostream>
int main() {
std::string str = "123";
int num = std::stoi(str);
std::cout << "Converted number is: " << num << std::endl; // Output: 123
}
```
阅读全文
相关推荐












