Would this work?

BlitzMax Forums/BlitzMax Programming/Would this work?

beanage(Posted 2009) [#1]
In other words, any idea why this obviously silently crashes at memcopy(), as arr[0] doesnt get printed?

Global arr	:Byte[4]
Global ivar	:Int = 99999999999

Print ivar

MemCopy( Varptr( arr ),Varptr( ivar ),4 )

Print arr[ 0 ]


(edit: oh sry, found it out myself: it needs to be varptr( arr[0] ))


ImaginaryHuman(Posted 2009) [#2]
Yah I was going to ask what you're trying to do, cus otherwise you were trying to copy the pointer to the array, not the first element of the array itself.


beanage(Posted 2009) [#3]
Target is to read the color Parts of a grabPixel():Int out of a Byte array... works fine!


Azathoth(Posted 2009) [#4]
Use 'arr' or 'Varptr(arr[0])' to get the address of an array.