Function

GLibstrdup_printf

Declaration

gchar*
g_strdup_printf (
  const gchar* format,
  ...
)

Description

Similar to the standard C sprintf() function but safer, since it calculates the maximum space required and allocates memory to hold the result. The returned string should be freed with g_free() when no longer needed.

The returned string is guaranteed to be non-NULL, unless format contains %lc or %ls conversions, which can fail if no multibyte representation is available for the given character.

Parameters

format const gchar*
 

A standard printf() format string, but notice [string precision pitfalls][string-precision]

 The data is owned by the caller of the function.
 The string is a NUL terminated UTF-8 string.
... none
 

The parameters to insert into the format string.

Return value

Returns: utf8
 

A newly-allocated string holding the result.

 The caller of the function takes ownership of the data, and is responsible for freeing it.
 The string is a NUL terminated UTF-8 string.