This question already has answers here:
to_string is not a member of std, says g++ (mingw)
                                
                                    (12个答案)
                                
                        
                                6年前关闭。
            
                    
这是一个已知问题,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/

最佳答案

您是否考虑过使用stringstream?

#include <sstream>

std::string itos(int i){
    std::stringstream ss;
    ss<<i;
    return ss.str();
}

关于c++ - 如何使用MinGW在C++中将int转换为std::string? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17863043/

10-11 22:57
查看更多