int -> char (label)...



hey,

i got a function that does a calculation and displays the result in a label.
The prblm is that i can't pass an int to gtk_label_new();

void calculate(GtkWidget *widget, GtkWidget **Entries) {
  GtkWidget *dialog, *label, *okay_button;
  gint res;
  gchar *txt1, *txt2, *txt3, *txt4, *b00;
  txt1=gtk_entry_get_text(GTK_ENTRY(Entries[0]));
  txt2=gtk_entry_get_text(GTK_ENTRY(Entries[1]));
  txt3=gtk_entry_get_text(GTK_ENTRY(Entries[2]));
  txt4=gtk_entry_get_text(GTK_ENTRY(Entries[3]));
/*values from the entries are converted into int + calculation*/
  res=atoi(txt1)+atoi(txt2)+atoi(txt3)+atoi(txt4);

  g_print("result: %d\n", res);/*here it works*/

/*trying to convert int to char to put it in the label*/
  snprintf(b00, sizeof(b00), "%d", res);

/*DIALOG*/
  dialog = gtk_dialog_new();
  gtk_window_set_title(GTK_WINDOW(dialog), "Dialog");
  gtk_widget_set_usize(dialog, 200, 100);
  label = gtk_label_new (b00);
...etc.

any idea?



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