在 C++ 中,您可以使用以下方法将整数类型 (int) 转换为字符串类型 (string):
```cpp
#include
#include
int main() {
int num = 123;
std::string str = std::to_string(num);
std::cout << "Integer to String: " << str << std::endl;
return 0;
}
```
在上面的示例中,`std::to_string()` 函数用于将整数 `num` 转换为字符串 `str`。这样就实现了从整数到字符串类型的转换。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:c++中string转int怎么实现