Unsafe_wrap C pointer after first element


How to wrap the contents of a C pointer, not from its first element, which is done with

unsafe_wrap(Array, ptr, 100)

but for example, from its 50th element?

With C address it would be

unsafe_wrap(Array, &ptr[49], 50)


Just do arithmetic on the pointer. The only difference is that you have to include the eltype size explicitly.

1 Like

Thanks, but that was actually my question. How do I do that?
(ptr is a pointer to double)

It should just be unsafe_wrap(Array, ptr+49*8, 50)

1 Like

That’s simple indeed.
Many thanks