标准库 itoa 函数
我在网上搜索并看到很多使用 itoa() 函数的代码&他们声称这个函数在 stdlib.h 中
我现在使用 2 个版本的 GCC:
(GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu4))
(GCC) 4.1.2 20080704 (Red Hat 4.1.2-44)
以及两者它们没有 itoa() 函数(我编译程序并错误:未定义对“itoa”的引用)。
有什么想法吗? 谢谢。
I searched on internet and saw a lot of code that uses itoa() function & they claimed that this function is in stdlib.h
I'm using 2 versions of GCC right now:
(GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu4))
(GCC) 4.1.2 20080704 (Red Hat 4.1.2-44)
and both of them does not have itoa() function (I compile the program & error: undefined reference to `itoa').
Any ideas?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
itoa()
不在标准 C 中 -snprintf()
是在其位置使用的函数(至少它可能是最简单的更改)。itoa()
isn't in standard C -snprintf()
is the function to use in its place (at least it's probably the simplest change to make).Wikipedia 给了你一个解释:它是一个非标准函数,但编译器通常通过标头提供它
处于非一致模式时。Wikipedia gives you an explanation: it's a non standard function, but compilers often provide it through the header
<stdlib.h>
while in non-conforming mode.这里是关于这个问题的好文章,从短语“How do I use itoa() with海湾合作委员会?”。文章还提供了几种 itoa() 的实现,性能比较均匀,请看一下。
Here is good article regarding this problem starting from phrase "How do I use itoa() with GCC?". Article also provides several itoa() implementations with even performance comparison, please take a look.