Pavan Manjunath Pavan Manjunath - 10 months ago 62
C Question

atoi is a standard function. But itoa is not. Why?

Why this distinction? I've landed up with terrible problems, assuming

to be in
and finally ending up with linking a custom version of
with a different prototype and thus producing some crazy errors.

So, why isn't
not a standard function? What's wrong with it? And why is the standard partial towards its twin brother

Answer Source

No itoa has ever been standardised so to add it to the standard you would need a compelling reason and a good interface to add it.

Most itoa interfaces that I have seen either use a static buffer which has re-entrancy and lifetime issues, allocate a dynamic buffer that the caller needs to free or require the user to supply a buffer which makes the interface no better than sprintf.