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

Anthony Lapadula al at unhd.unh.edu
Wed Apr 3 03:32:53 AEST 1991


In article <3739 at jethro.Corp.Sun.COM> fguille at France.Sun.COM 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;
>              }
>[....]
>
>       static char retbuf[6];         /* biggest int: 32768 */

I wanted to stay out of this discussion.  I really did....

I know this thread grew out of an April Fool's joke, but I just can't
let this pass.

Even if you know that your system has 16-bit int's (which is a poor
assumption -- we should know by now that all the world's a VAX :-),
itoa could still be requested to print out, say, "-20000", which
requires a buffer of size *7*.

-- Anthony (uunet!unhd!al, al at cs.unh.edu) Lapadula

"I would agree with you if you were right."  --  Dr Sayer, "Awakenings"



More information about the Comp.lang.c mailing list