Getting An Array Of Strings From A Char** With FFI And Ruby
Join the DZone community and get the full member experience.Join For Free
This code adds a method to the FFI::Pointer class that makes it easy to unravel an array of null terminated strings from a char** type.
require 'ffi' class FFI::Pointer def read_array_of_string elements =  loc = self until ((element = loc.read_pointer).null?) elements << element.read_string loc += FFI::Type::POINTER.size end elements end end
Strings Data structure
Opinions expressed by DZone contributors are their own.