Re: numerical buttons labels cont'd URGENT



> > > > void
> > > > on_button_click_event2 (GtkWidget *button, gpointer user_data)
> > > > {
> > > >   char *str;
> > > >   int i;
> > > >   gtk_label_get(GTK_LABEL(GTK_BIN(button)->child), &str);
> > > >   i = atoi(str);
> > > >   i--;
> > > >   sprintf(str,"%i",i);
> ARGH! You're writing in UNALLOCATED memory. *EVERYTHING* could happen,
> including fdisk /dev/hda :-)
> Change the previous char *str to char str[16] ...

if i use char str[16], it says:

warning: passing arg 2 of `gtk_label_get' from incompatible pointer type

so it seems gtk_label_get does not work with pre-declared strings...in
fact i was thinking that gtk_label_get was allocating memory, writing
into it, and returning to me the pointer to this freashly allocated
string...wich is why i used char *str at first !

Is there a way to print non "..." strings like char* with gtk, or is it
me ?
the only way that seems to work is 
gtk_label_set_text(GTK_LABEL(user_data), "XXXX" );




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