Struct class examples
Factor handbook > C library interface > Struct classes

Next:Defining struct classes

A struct with a variety of fields:
USING: alien.c-types classes.struct ; STRUCT: test-struct { i int } { chicken char[16] } { data void* } ;

Creating a new instance of this struct, and printing out:
test-struct <struct> .

Creating a new instance with slots initialized from the stack:
USING: libc specialized-arrays ; SPECIALIZED-ARRAY: char 42 "Hello, chicken." char >c-array 1024 malloc test-struct <struct-boa> .