问题描述
这是一个已知问题,std :: to_string不起作用.甚至std :: itoa都不适合我.如何将int转换为字符串?我不太在乎性能,我所需要的只是在不太慢的情况下工作.
It is a known issue that std::to_string does not work. Even std::itoa didn't work for me. What can I do to convert an int to a string? I don't care much about performance, all I need it is to work without being too slow.
我已经安装了最新的mingw 32,std :: to_string仍然不起作用.我从这里安装它: http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.1/32-bit/threads-win32/sjlj/
I have the latest mingw 32 installed, std::to_string still does not work. I installed it from here: http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.1/32-bit/threads-win32/sjlj/
推荐答案
您是否考虑过使用字符串流?
Have you considered using a stringstream?
#include <sstream>
std::string itos(int i){
std::stringstream ss;
ss<<i;
return ss.str();
}
这篇关于如何使用MinGW在C ++中将int转换为std :: string?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!