New 'n' Improved comp.lang.c FAQ List
Dave Turner
dmturne at PacBell.COM
Fri Apr 5 06:17:05 AEST 1991
In article <849 at saxony.pa.reuter.COM> dgil at pa.reuter.COM (Dave Gillett) writes:
.In <1991Apr1.203024.19679 at unlv.edu> grover at big-joe.cs.unlv.edu (Kevin Grover) writes:
.> char *itoa(int i)
.> {
.> static char retbuf[5]; /* biggest int: 32769 */
.> sprintf(retbuf, "%d", i);
.> return retbuf;
.> }
. Bzzzt!
. For this purpose, the "biggest" integer (assuming 16-bit ints, as Kevin
.has...) is
. -32768
. That's *6* characters long.
Bzzzt!
Counting the \0 placed at the end of the string by sprintf,
that's *7* characters long.
--
Dave Turner 415/823-2001 {att,bellcore,sun,ames,decwrl}!pacbell!dmturne
More information about the Comp.lang.c
mailing list