Complete.Org: Mailing Lists: Archives: discussion: March 2000:
[aclug-L] Re: C question: double to string?
Home

[aclug-L] Re: C question: double to string?

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: discussion@xxxxxxxxx
Subject: [aclug-L] Re: C question: double to string?
From: Brian Chapman <tchapman@xxxxxxxxxxxxx>
Date: Sun, 05 Mar 2000 00:56:15 -0600
Reply-to: discussion@xxxxxxxxx

Steven Saner wrote:
> On Sun, Mar 05, 2000 at 12:11:19AM -0600, Brian Chapman wrote:
> > sprintf (buffer, "%f", number);
> >
> 
> Of course this does assume that you are sure that your buffer is big
> enough to hold the string. You might want to add some flags in the
> format that limits the resulting string to a certain size, such as:
> 
> sprintf(buffer, "%10.10f", number);

heh...well if we're getting pedantic about it, that's not true. The
width specified for the integer portion of the decimal is the MINIMUM
width. Therefore, its possible to have a buffer overrun in your case
also. The entire number will be printed regardless.

Perhaps you were thinking of the '%s' string specifier.

-- This is the discussion@xxxxxxxxx list.  To unsubscribe,
visit http://tmp2.complete.org/cgi-bin/listargate-aclug.cgi


[Prev in Thread] Current Thread [Next in Thread]