如何使用 MinGW 在 C++ 中将 int 转换为 std::string?

Vel*_*tov 0 c++ mingw

std::to_string 不起作用是一个已知问题。甚至 std::itoa 也不适合我。我该怎么做才能将 int 转换为字符串?我不太关心性能,我所需要的只是工作而不会太慢。

编辑:我安装了最新的 mingw 32,std::to_string 仍然不起作用。我从这里安装它:http : //sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.1/32-bit/threads-win32/sjlj/

fat*_*gee 5

您是否考虑过使用字符串流?

#include <sstream>

std::string itos(int i){
    std::stringstream ss;
    ss<<i;
    return ss.str();
}
Run Code Online (Sandbox Code Playgroud)