C Array new instance

The Array object allows you to define a C array. To create a new C array instance from this definition, simply call this object with or without initialization values.

Notes

To initialize Array fields, you can provide as arguments :
  • A table that contains the fields with the corresponding values (each sub array is initizalized as a sub table).
  • If no initialization value is provided, all array elements are set to 0 or NULL

Example

local c = require 'c' -- Defines a C array with 3 rows of 4 chars local CharArray = c.Array("c", 3, 4) -- Creates a new CharArray instance with an initialization table local array = CharArray { { "a", "b", "c", '\0' }, { "d", "e", "f", '\0' }, { "g", "h", "i", '\0' } } -- prints the first row as a char Pointer print(c.Pointer(array[0]))