cast

Boris Shomodjvarac shomodj.N at SPAM.slashmail.org
Fri Nov 17 05:46:37 PST 2006


On Fri, 17 Nov 2006 15:30:53 +0200, Max Samuha wrote:

> On Fri, 17 Nov 2006 14:01:50 +0100, Boris Shomodjvarac
> <shomodj.N at SPAM.slashmail.org> 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]
> or
> *cast(int*)(buffer.ptr + 4)

Thanks it works :) I also want to thank Bill and Gordon...



More information about the Digitalmars-d-learn mailing list