Re: label with format string



Here's another version, using glib stuff alone:

/* I work with the 1.2.x version of g* */

void lblprintf (GtkWidget *lbl, char *pszFormat, ...)
  {
  const char *pszFmt = pszFormat ;
  char *pszMsg = NULL ;
  int ic = 0 ;

  va_start (va, pszFormat) ;
  pszMsg = malloc (ic = g_printf_string_upper_bound (pszFmt, va)) ;
  g_vsnprintf (pszMsg, ic, pszFmt, va) ;
  va_end (va) ;
  
  gtk_label_set_text (GTK_LABEL (lbl), pszMsg) ;
  free (pszMsg) ;
  }




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