07-10-2005, 06:57 AM
I can't figure this out...
I make a pointer, and make a function return an address to this pointer.
This address returned to the pointer from the function is the start address to an array which contains some numbers.
First print goes ok, but second one gives something random.
I've also tried +2 and +4 on the second print statement without results.
And I've tried to make a simple integer variable, and let the function return its address to this variable, and then give the pointer the value of this integer.
Any ideas?
:-?
I make a pointer, and make a function return an address to this pointer.
This address returned to the pointer from the function is the start address to an array which contains some numbers.
First print goes ok, but second one gives something random.
I've also tried +2 and +4 on the second print statement without results.
And I've tried to make a simple integer variable, and let the function return its address to this variable, and then give the pointer the value of this integer.
Any ideas?
:-?
Code:
declare function MakeList ()
dim my_pointer as integer ptr
my_pointer = MakeList()
print *my_pointer
print *(my_pointer + 1)
sleep
function MakeList ()
dim MyList(4) as integer
MyList(0) = 5
MyList(1) = 10
MyList(2) = 20
MyList(3) = 40
MyList(4) = 80
return @MyList(0)
end function
It's the difference between asking someone how much flour goes into pancakes, and handing them a sorry mix of oozing green goo and asking them to fix it." - Deleter
-Founder & President of the No More Religion Threads movement-
-Founder & President of the No More Religion Threads movement-