lua_pushfstring
[-0, +1, e]
const char *lua_pushfstring (lua_State *L, const char *fmt, ...);
Pushes onto the stack a formatted string and returns a pointer to this string. It is similar to the ISO C function sprintf
, but has some important differences:
- You do not have to allocate space for the result: the result is a Lua string and Lua takes care of memory allocation (and deallocation, through garbage collection).
- The conversion specifiers are quite restricted. There are no flags, widths, or precisions. The conversion specifiers can only be '
%%
' (inserts the character '%
'), '%s
' (inserts a zero-terminated string, with no size restrictions), '%f
' (inserts alua_Number
), '%I
' (inserts alua_Integer
), '%p
' (inserts a pointer as a hexadecimal numeral), '%d
' (inserts anint
), '%c
' (inserts anint
as a one-byte character), and '%U
' (inserts along int
as a UTF-8 byte sequence).
Unlike other push functions, this function checks for the stack space it needs, including the slot for its result.
Please login to continue.