Pointers and offsets

Bauss via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jan 13 17:16:52 PST 2015


Is it possible to access a pointer by its offsets.
Ex. write a 32bit integer to a byte pointer at ex. offset 4.

To give an example in C# you can do this:
fixed (byte* Packet = Buffer) // Buffer would be a byte array

And then to set the value of a specific offset
*((TYPE*)(Packet + OFFSET))

Where TYPE could be replaced by ex. uint and OFFSET by 4

I tried to look here:
http://dlang.org/arrays.html

But couldn't seem to find anything like it.


More information about the Digitalmars-d-learn mailing list