Subject: [ruby-ffi] char array inside struct |
From: daniel åkerud <daniel.akerud@gmail.com> |
Date: 10/30/09 7:04 AM |
To: ruby-ffi |
I have a char array baked into a struct (not a pointer), and I just want a confirm that I do it the correct/intended way. struct { uint8 Value; uint8 String[SIZE_OF_ARRAY]; } MyArray_t; class MyArray_t < FFI::Struct layout :Value, :uint8, :String, [:uint8, SIZE_OF_ARRAY] end my_array_struct = MyArray_t.new c_function(my_array_struct.pointer) #the c_function fills the char array str = my_array_struct[:String].to_s # is to_s the correct function to retrieve a string? read_string doesn't work. Thanks, /D