Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在互联网上搜索并看到很多使用 itoa() 函数的代码,他们声称这个函数在 stdlib.h
我现在使用 2 个版本的 GCC:
(GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu4))
(GCC) 4.1.2 20080704 (红帽 4.1.2-44)
并且它们都没有 itoa() 函数(我编译程序和错误:未定义对 `itoa' 的引用)。
有任何想法吗?谢谢。
itoa()不在标准 C 中 -snprintf()是在其位置使用的函数(至少它可能是最简单的更改)。
itoa()
snprintf()
维基百科给你一个解释:它是一个非标准函数,但编译器通常<stdlib.h>在非一致性模式下通过标头提供它。
<stdlib.h>
这是一篇关于这个问题的好文章,从“How do I use itoa() with GCC?”这个短语开始。文章还提供了几个 itoa() 实现,性能比较均匀,请看。