Re: want to add number to label
- From: Tim Flechtner <timf trdlnk com>
- To: edward hage <edha xs4all nl>
- Cc: gtk-list gnome org
- Subject: Re: want to add number to label
- Date: Tue, 18 Mar 2003 15:15:00 -0600
gtk_label_new expects a pointer to a character array (char *), but
simply telling the compiler that nr is a pointer to a character array by
casting it to char * does not make it a valid array. (i could tell you i
was a flounder, but trust me, its still not true). you need to convert
nr to a character representation of nr's floating point value. one way
to do this is by using sprintf. do a 'man sprintf', but it will look
something like:
char buf[20];
sprintf(buf, "%f", nr);
-tim
edward hage wrote:
Hello, I think I have a simple problem but I cannot figure out how to
get a float on a label. It is designed for a string, like "this is a
button" but I want to show a float value.
So my question is how can I turn a float into a suitable format to stick
to a label?
Example that does not work:
GtkWidget *button;
float nr;
nr = 3.123;
button = gtk_label_new ((char *) nr); ????
Thank you, Edward
_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]