Originally Posted by Sebastiani
There is such a thing as compile-time asserts. In C++ that typically means static_assert, or in C various macros like C_ASSERT are used. These are used precisely for finding mistakes at compile time, without having to debug the program. That is what should be used in this case.
Also, compile-time asserts are meant to be enabled for all project build types, which is fine since they have no run-time impact.
Make sure you test your function for an input value of -2147483648. An implementation that does not use an unsigned type internally will normally fail with that value, asuming 32-bit ints.
Quite often you don't have a sprintf(). On an embedded system it might not be provided. On MS Windows you have wsprintf(), but it doesn't handle floating point values (no kidding), so you have to implement your own. Whilst my_atoi couldn't be used as it stands, it would be simple to retype char as w_char.
Originally Posted by Barney McGrew