New 'n' Improved comp.lang.c FAQ List

Tim Roberts timr at gssc.UUCP
Thu Apr 4 04:53:36 AEST 1991


In article <3739 at jethro.Corp.Sun.COM> fguille at France.Sun.COM writes:
:>bls at u02.svl.cdc.com (Brian Scearce) writes:
:>    Almost, but not quite, Mr. Grover.  The *really* correct version of this:
:>            char *itoa(int i) {
:>                static char retbuf[5];         /* biggest int: 32768 */
:>                sprintf(retbuf, "%d", i);
:>                return retbuf;
:>              }
:>Should'nt the *really really correct* version allocate an extra character
:>in the retbuf array for the end of string delimiter \0 ???
:>
:>I will just say that a *just a little bit more correct* version should read:
:>
:>       static char retbuf[6];         /* biggest int: 32768 */

Shouldn't the *really truly one-true-God correct* version of this read:

        static char retbuf[6];         /* biggest int: 32767 */
    
And isn't this really really just a little bit more silly than we all need?



-- 
timr at gssc.gss.com	Tim N Roberts, CCP	Graphic Software Systems
						Beaverton, OR

This is a very long palindrome. .emordnilap gnol yrev a si sihT



More information about the Comp.lang.c mailing list