pass struct array by reference

 

Hello,

I want to know how to pass an array which is in another array struct to a function by reference.


struct SRLines
{
   string name;
   double price;
};
struct CiCSupAndResLines // Support and Resistance Line from SmartLine Indicator
{
   string symb;
   SRLines M1[];
   SRLines M5[];
   SRLines M15[];
   SRLines M30[];
   SRLines H1[];
   SRLines H4[];
   SRLines D1[];
   SRLines W1[];
   SRLines MN[];   
};
CiCSupAndResLines CiCSuppRes[28];

Now I want to call a function and pass only a member array from CiCSuppRes[] array.

Something like this:

SetLineInStruct(CiCSuppRes[1].M5);


void SetLineInStruct(SRLines &arr){

//-- do something
}

but it doesn't work that way. Is it even possible?

Thank you.

Best regards

Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
  • www.mql5.com
//| Expert initialization function                                   | //| Expert deinitialization function                                 | //| Expert tick function                                             | //| test1                                                            |...
 
You are passing an array (M5). Your function doesn't take an array, it takes a single SRLines. Change your function.
void SetLineInStruct(SRLines &arr[]){
   //-- do something with the array arr.
}
 
many thanks for the fast help William.(again)
Reason: