Passing Array as a function input argument

 

Hi Guys,

I am writing a simple loop through array elements as a .dll.

Using

#import "Path"

as usual but I am unsure as to hoe to declare the function and then call it. I am using:

declaration:

int arraytest(int a, int b[]);
#import


Call in an Alert whatever this function returns:

Alert(arraytest(5,cc[]));

This doesn't compile as it is throwing reference errors on b[].

Have you got any ideas?

Thank you so much for you help and interest.



dsds

 
Arrays must be passed by reference, not value.
 
WHRoeder:
Arrays must be passed by reference, not value.
Thanks. Could you kindly provide an example?
 
 

Can I get some help here guys please, so I do #import the relevant .dll and then before closing the #import statement I refer to my function as

int arraytest(int a, int & b);

Then somewhere along the code I have defined the following array:

int cc[5] = { 1, 2, 3, 4, 5 };


and try to pass it as argument in the function in the following way:

Alert(arraytest(5,cc[]));


That throws a compilation error '] expression expected'

Any ideas?

Thanks

 
Alert(arraytest(5,cc[]));

You have to pass variables. cc[] is not a variable name.

 
Vlaser91:

Can I get some help here guys please, so I do #import the relevant .dll and then before closing the #import statement I refer to my function as

Then somewhere along the code I have defined the following array:


and try to pass it as argument in the function in the following way:


That throws a compilation error '] expression expected'

Any ideas?

Thanks


Alert(arraytest(5,cc));
 
zirkoner:

Thanks, what I am getting is " 'cc' parameter conversion not allowed." during compile!
 
WHRoeder:

You have to pass variables. cc[] is not a variable name.

How do you think I should address this?
 
int arraytest(int a, int & b);
pass what the function expects.