【发布时间】:2013-11-17 18:31:25
【问题描述】:
将整数转换为以 10 为底的 char*
std::itoa(ConCounter, ID, 10);
ConCounter 为整数,ID 为 char*,10 为底数
它说 iota 不是 std 的成员,没有 std 它不会被声明。我知道这是一个非标准函数,但我包含了它的所有库,但它仍然看不到它。
有什么方法可以做到以上几点?有什么快速的一号线吗? 我尝试了以下方法;
std::to_string //it's not declared for me when using mingw, it doesn't exist.
snprintf/sprintf //should work but it gives me the "invalid conversion from 'int' to 'char *'" error
std::stoi //has same problem as iota
【问题讨论】:
-
to_string是 a) 在 C++11 中和 b) 在较新版本的 MinGW 中修复。 -
顺便说一句,
std::iota与itoa完全不同。 -
@Chris 哪个新版本? This 不会在 MingW g++ (GCC) 4.8.1 上编译
-
@P0W,我似乎记得它已在主要版本中得到修复,但它绝对适用于 MinGWBuilds 4.8.1。
-
@chris i.troll.ws/376fe7ab.jpg
标签: c++ windows string int itoa