cast

Bill Baxter wbaxter at gmail.com
Fri Nov 17 05:31:39 PST 2006


Boris Shomodjvarac wrote:
> Hi,
> 
> I have a array of ubyte-s and need to cast for example from 4-th element
> to 8-th element into int, anyone knows how to do that? 
> 
> example:
> 
> ubyte buffer[1024];
> 
> listener.receiveFrom(buffer, address);
> 
> writefln("Transaction ID: %s", cast(int)buffer[4 .. 8]);
> 
> 
> Thanks.

*cast(int*)&buffer[4];

But you better be sure the endianness of the data is the same as the 
platform you're reading it on.

--bb



More information about the Digitalmars-d-learn mailing list