[racket] Filling char arrays inside cstructs

From: Danny Yoo (dyoo at hashcollision.org)
Date: Wed Feb 6 16:22:29 EST 2013

On Wed, Feb 6, 2013 at 10:07 AM, Diogo F. S. Ramos <diogofsr at gmail.com> wrote:
> How do I fill a char array, inside a cstruct, with a byte string?
>
> I'm using the following code to do it, but is there a better way?

Hi Diogo,

I'm also beginning to use the FFI, and starting to collect examples for use.


Here's your example:

    https://github.com/dyoo/ffi-tutorial/tree/master/ffi/tutorial/examples/struct-with-array



The core files you can take a look at are:


The FFI code:

    https://github.com/dyoo/ffi-tutorial/blob/master/ffi/tutorial/examples/struct-with-array/struct-with-array.rkt



and the usage:

    https://github.com/dyoo/ffi-tutorial/blob/master/ffi/tutorial/examples/struct-with-array/test-struct-with-array.rkt



Best of wishes!

Posted on the users mailing list.