[Glade-users] How To Send Array Element To Label?

Tristan Van Berkom tvb at gnome.org
Wed Nov 9 15:47:31 EST 2005


Bob Jones wrote:
> I have an array:
>  
> char array1[] = "abcdefg";

  o array1 here is a null terminated charachter array
    (in other words a string);
  o array1[3] is a charachter in an array (a short intager describing
    the ascii code for; in this case; the letter "d").
  o gtk_label_set_text () takes a "string" as a second argument.

if you call it like so:
      gtk_label_set_text (label, &array[3]); // (note the &)
then the label should display the string "defg".

if you only want to show the letter "d", then you'll need to make a
string; something like:

char *string = g_strdup_printf ("%c", array[3]);
gtk_label_set_text (label, string);

Cheers,
                             -Tristan


More information about the Glade-users mailing list