Function

GLibsprintf

Declaration

gint
g_sprintf (
  gchar* string,
  const gchar* format,
  ...
)

Description

An implementation of the standard sprintf() function which supports positional parameters, as specified in the Single Unix Specification.

Note that it is usually better to use g_snprintf(), to avoid the risk of buffer overflow.

glib/gprintf.h must be explicitly included in order to use this function.

See also g_strdup_printf().

Available since:2.2
This function is not directly available to language bindings

Parameters

string gchar*
 

A pointer to a memory buffer to contain the resulting string. It is up to the caller to ensure that the allocated buffer is large enough to hold the formatted result.

 The data is owned by the caller of the function.
 The value is a NUL terminated UTF-8 string.
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 value is a NUL terminated UTF-8 string.
...
 

The arguments to insert in the output.

Return value

Returns: gint
 

The number of bytes printed.