Re: [gtkmm] convert double to char
- From: Chris Vine <chris cvine freeserve co uk>
- To: Paul Davis <paul linuxaudiosystems com>, SMS WebMaster <sms 4-sms com>
- Cc: gtkmm list <gtkmm-list gnome org>
- Subject: Re: [gtkmm] convert double to char
- Date: Sat, 6 Dec 2003 20:08:07 +0000
On Monday 01 December 2003 10:29 pm, Paul Davis wrote:
>
[snip]
> >Anyone know how can I make this code work :
> >
> >[code]
> >double DegreeLong=1.2011;
> > m_Entry2.set_text(DegreeLong);
> >[/code]
>
> 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());
Chris.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]