Pointer:dec()method

Decrements the Pointer memory position to one or more position, meaning it moves by the size of the data type it points to.

Return value

The function returns the decremented Pointer for convenience.

Example

local str = c.string("C FFI module") -- Creates a Pointer to this string local pstr = c.Pointer(str) local inv = c.Pointer(str) inv = inv + #str-1 for i=#str-1,0, -1 do -- set the inv.content (a char) from the pstr.content inv.content = pstr.content -- Print the inv pointer as a string print(inv) -- and increment the string pointer by one char position inv:dec(); end