Re: [gtkmm] convert double to char
- From: Paul Davis <paul linuxaudiosystems com>
- To: Chris Vine <chris cvine freeserve co uk>
- Cc: SMS WebMaster <sms 4-sms com>, gtkmm list <gtkmm-list gnome org>
- Subject: Re: [gtkmm] convert double to char
- Date: Sat, 06 Dec 2003 17:16:00 -0500
>> this is an extremely basic C++ question. really way too basic and
>> general for this list.
>>
>> char buf[32];
>>
>> snprintf (buf, sizeof(buf), "%g", DegreeLong);
>> m_Entry2.set_text (buf);
>
>Indeed so, but as we are using C++, stringstreams seem a better choice, and
>make buffer overruns impossible:
>
> std::ostringstream strm;
> strm << DegreeLong;
> m_Entry2.set_text(strm.str());
all true. however, if you can find me any value of a double that will
not fit into a 32 character representation, i'd like to see it. in
addition, snprintf() also makes a buffer overrun impossible in more or
less the same way. the overhead of stringstreams can be quite
significant, which is why i tend to avoid using them.
--p
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]