Re: [gtk-list] Q: (gtk-entry) convert integer/float to char/string




Daniel Hops <Daniel.Hops@eed.ericsson.se> writes:

> Hello,
> 
> in my gtk app I have to calculate digits (integers/floats) and want to
> insert them in entries via "gtk_entry_set_text ()".
> But this method only accepts chars. How can I easily make a function
> like itoa? Or is there another way?

  char *str = g_strdup_printf ("%f", my_double);
  gtk_entry_set_text (GTK_ENTRY (entry), str);
  g_free (str);

Not the most efficient way, but easy and efficient enough.

Regards,
                                        Owen



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]