The itoa
function isn't standard probably for the reason is that there is no consistent definition of it. Different compiler and library vendors have introduced subtly different versions of it, possibly as an invention to serve as a complement to atoi
.
If some non-standard function is widely provided by vendors, the standard's job is to codify it: basically add a description of the existing function to the standard. This is possible if the function has more or less consistent argument conventions and behavior.
Because multiple flavors of itoa
are already out there, such a function cannot be added into ISO C. Whatever behavior is described would be at odds with some implementations.
itoa
has existed in forms such as:
void itoa(int n, char *s); /* Given in _The C Programming Language_, 1st ed. (K&R1) */
void itoa(int input, void (*subr)(char)); /* Ancient Unix library */
void itoa(int n, char *buf, int radix);
char *itoa(int in, char *buf, int radix);
Microsoft provides it in their Visual C Run Time Library under the altered name: _itoa
.
Not only have C implementations historically provided it under differing definitions, C programs also provide a function named itoa
function for themselves, which is another source for possible clashes.
Basically, the itoa
identifier is "radioactive" with regard to standardization as an external name or macro. If such a function is standardized, it will have to be under a different name.
atoi
is historical,itoa
isn't. You shouldn't really useatoi
anyway,strto(u)l(l)
is what you should use. For the other direction,s(n)printf
. – Ikedaitoa
isn't a standard function can you include what the interface contract for theitoa
function that you want to discuss should be? (Doing this may answer your question.) – Masjiditoa
in mind? – Masjidstrcpy
but they are all in thestandard
bus! – Sherrisherrie