Re: How to change float to char



    Flavio> I need to print float numbers in a gtk label and this widget
    Flavio> only accept gchar in your text parameter, I want to know if
    Flavio> exists some type of routine that changes float number in format
    Flavio> a.bcde to char format "a.bcde".

Check out g_snprintf in the glib reference manual (section: String Utility
Functions).  I believe you call it pretty much like you would sprintf, with
the added safety feature that you provide the length of the output buffer so
it doesn't scribble past the end of it:

    g_snprintf(buf, len_buf-1, "%6.4f", myfloat);

-- 
Skip Montanaro (skip pobox com)
(847)971-7098




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