itoa'd you so?

Bryan Sant bryan.sant at
Wed Sep 19 16:23:38 MDT 2007

On 9/19/07, Michael L Torrie <torriem at> wrote:
> Well, if I understand your code correctly, you're returning a char *
> pointer (likely const char *) to the internal buffer of the out
> stringstream, correct?  If so, then on return the caller receives a
> pointer to the internal buffer of the out object which lived in the
> stack frame of the itoa call, which no longer exists.

You're exactly right.  That's why itoa in the C standard lib has you
pass your own char[] into them.  They're expecting the caller to
allocate and babysit the buffer.

Oh the joys of life with manual memory management :-).


More information about the PLUG mailing list