C Error: undefined reference to '_itoa'

女生的网名这么多〃 提交于 2019-12-03 06:36:43
Brian Roach

itoa is not part of the standard. I suspect either -ansi is preventing you from using it, or it's not available at all.

I would suggest using sprintf()

If you go with the c99 standard, you can use snprintf() which is of course safer.

char buffer[12];
int i = 20;
snprintf(buffer, 12,"%d",i);

This here tells you that during the compilation phase itoa is unknown:

warning: implicit declaration of 'itoa'

so if this function is present on your system you are missing a header file that declares it. The compiler then supposes that it is a function that takes an unspecific number of arguments and returns an int.

This message from the loader phase

undefined reference to '_itoa'

explains that also the loader doesn't find such a function in any of the libraries he knows of.

So you should perhaps follow Brian's advice to replace itoa by a standard function.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!