Re: label with format string



On Tue, 2003-09-09 at 11:46, Nix N. Nix wrote:
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) ;

g_strdup_vprintf would be a lot easier ;-)

Havoc





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