Hero6
http://www.hero6.org/forum/

How to pass an array parameter to a function in AGS
http://www.hero6.org/forum/viewtopic.php?f=17&t=63
Page 1 of 1

Author:  bdimopoulos [ Fri, 22 Aug 2014 23:23 ]
Post subject:  How to pass an array parameter to a function in AGS

Hello everyone.

I was trying to find a way to pass an array as a parameter to a function in AGS and it turned out to be an exercise in frustration, so I simply wanted to share that experience with you and hopefully spare someone else.

Lets say you have a function like this:
function boo(int x[]) {
//code goes here
}


If you try to call it like this it will fail with a "Type mismatch: cannot convert int* to int[]" error:
int my_x[10];
boo(my_x);


The correct way to call this is:
int my_x[] = new int[10];
boo(my_x);


Just FYI in case you need it at some point

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/