int function( int& array[] ) { ... };
No! If you are passing an array as an argument, treat it as such. It is an array of many elements. You can't just multiply it by "2" and just get a single value.
You can only return a single value from a function but you can alter the contents of an array passed to the function.
If you want to return an array value, then do something like this:
void someotherfunction(void) { int list[] = { 1, 2, 3, 4 }, results[]; function( list, results ); }; bool function( int& alist[], int& blist[] ) { int size = ArraySize( alist ); if( size > 0 ) { if( ArrayResize( blist, size ) >= size ) { for( int i = 0; i < size; i++ ) blist[i] = alist[i] * 2; return true; }; }; return false; };
This way, you can read the values from "alist" and assign different values to "blist". The above code is untested and uncompiled, only to serve as an example.
EDIT: Please note that I edited this post multiple times.
No! If you are passing an array as an argument, treat it as such. It is an array of many elements. You can't just multiply it by "2" and just get a single value.
You can only return a single value from a function but you can alter the contents of an array passed to the function.
If you want to return an array value, then do something like this:
This way, you can read the values from "alist" and assign different values to "blist". The above code is untested and uncompiled, only to serve as an example.
EDIT: Please note that I edited this post multiple times.
wonderful worked!! thanks
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
but when there is an array of list
how can i modify the function so it works for array
Thanks