How can I map bytes to a matrix of structures?
teo
teo.ubuntu at yahoo.com
Fri Sep 9 08:19:06 PDT 2011
Here is an example of what I am after:
struct DATA
{
ubyte D1;
ubyte D2;
ubyte D3;
ubyte D4;
}
void main()
{
ubyte[16] a = [ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x01,
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 ];
auto b = (cast(DATA*)a.ptr)[0 .. 4];
auto c = (cast(DATA[]*)b.ptr)[0 .. 2][0 .. 2];
}
I need to have a DATA[2][2]. That code compiles but gives me a
segmentation fault.
More information about the Digitalmars-d-learn
mailing list