Does anyone know what is the command to copy from one structure to another structure?
Have you read this topic (https://www.mql5.com/en/docs/basis/types/classes)?
It depends on structure which you want to copy.
Structures that do not contain strings or objects of dynamic arrays are called simple structures; variables of such structures can be freely copied to each other, even if they are different structures. Variables of simple structures, as well as their array can be passed as parameters to functions imported from DLL.
- www.mql5.com
Have you read this topic (https://www.mql5.com/en/docs/basis/types/classes)?
It depends on structure which you want to copy.
I was more looking at a function to copy structures of same type without multiple assignment statement of each element in the structure. Sort of like memory copy in C.
For example,
struct newStruct { int x; double y};
newStruct A, B;
memcpy(B, A, sizeof(A)); // copy A to B
I was more looking at a function to copy structures of same type without multiple assignment statement of each element in the structure. Sort of like memory copy in C.
For example,
struct newStruct { int x; double y};
newStruct A, B;
memcpy(B, A, sizeof(A)); // copy A to B
You can do it easier.
//+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ struct newStruct { int x; double y; }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int OnStart() { newStruct A={2,2}; newStruct B; B=A; //--- return(0); }
You can do it easier.
Oh, I didnt know an assignment statement copies one structure to another. how about structure involving string like mqlparam?
MqlParam a;
MqlParam b;
can I do a=b? will b.string_value be copied too?
- www.mql5.com
It isn't simple structure (https://www.mql5.com/en/docs/basis/types/classes), so you can't. You will get an error if you try.
'b' - structure have objects and cannot be copied
- www.mql5.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Does anyone know what is the command to copy from one structure to another structure?