Talk:Increment a numerical string: Difference between revisions
Content added Content deleted
(C int2str) |
m (→C int2str: Typo.) |
||
Line 1: | Line 1: | ||
== C int2str == |
== C int2str == |
||
I removed <tt>int2str</tt> in |
I removed <tt>int2str</tt> in [http://rosettacode.org/mw/index.php?title=Increment_a_numerical_string&diff=83245&oldid=81783 a recent revision] because of "various bugs". For the record the issues I noticed are: |
||
# The integer input has to be greater than 0, otherwise the output is bogus. |
# The integer input has to be greater than 0, otherwise the output is bogus. |
Revision as of 02:29, 31 May 2010
C int2str
I removed int2str in a recent revision because of "various bugs". For the record the issues I noticed are:
- The integer input has to be greater than 0, otherwise the output is bogus.
- The occasional use of a static char buffer inside this function is unnecessary and makes it non-threadsafe.
- The result is written starting from the end of the buffer rather than the beginning (unlike sprintf and itoa).
- The given buffer is assumed to be 32 chars.
There's a standard way to convert integers to strings so I don't think it's necessary to reinvent this wheel. A well-tested itoa implementation might still be interesting though. Rasalas 02:28, 31 May 2010 (UTC)