开发者

Stdlib itoa function

开发者 https://www.devze.com 2022-12-10 06:39 出处:网络
I searched on internet and saw a lot of code that uses itoa() function & they claimed that this function is in stdlib.h

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:

  1. (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu4))

  2. (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 i开发者_StackOverflow中文版deas? Thanks.


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 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消