Re: integer to characters
From: Micah Cowan (micah_at_cowan.name)
Date: 10/29/03
- Next message: Micah Cowan: "Re: denying inheritance"
- Previous message: Micah Cowan: "Re: 2-dimensional arrays and functions"
- In reply to: Gene Wirchenko: "Re: integer to characters"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 29 Oct 2003 11:41:10 -0800
Gene Wirchenko <gwirchenkoEXCEPT@CAPITALSwencomine.com> writes:
> On Wed, 29 Oct 2003 06:47:39 +0000 (UTC), Richard Heathfield
> <dontmail@address.co.uk.invalid> wrote:
>
> >Alan Kelon wrote:
>
> [snip]
>
> >> Yes, you're correct. Sorry about this, I found this information from my
> >> compiler's help, but I tried to find itoa from The C Programming Language
> >> by K&R and I found this implementation:
> >
> >I don't understand why you need it. What is wrong with:
> >
> >sprintf(s, "%d", i);
> >
> >?
>
> Possible buffer overflow.
Yes, but so did the itoa(). However, sprintf() is defined by the
Standard, itoa() is not.
The buffer-safe version, snprintf(), is not available in C90.
The problem is easily averted by first checking your buffer size
before using sprintf().
-- Micah J. Cowan micah@cowan.name
- Next message: Micah Cowan: "Re: denying inheritance"
- Previous message: Micah Cowan: "Re: 2-dimensional arrays and functions"
- In reply to: Gene Wirchenko: "Re: integer to characters"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|