Pointer.content readwrite>
The Pointer.content property access the memory content of the pointed memory, as a Value
- This property permits pointer dereferencing, the operation of accessing/manipulating the data value that a pointer points to.
- The type of the Value depends on the Pointer.type property.
- Casting a Pointer to another Pointer type is possible using the Pointer.as() method.
Return value
Returns the pointed memory content as a
Value
Example
local c = require "c"
-- Create a C integer Value, that contains the number 10
local int = c.int(10)
-- Creates a Pointer to this Value
local int_ptr = c.Pointer(int)
-- Gets the content of the pointed memory to a new integer Value
local derefer = int_ptr.content
-- Changes the pointed memory content to 20 instead of 10
int_ptr.content = 20
-- int Value now contains 20 (defer Value is still 10)
print("int =", int)
print("derefer =", derefer)