Use a "union" to overlay the structure on a uchar array, so that you can interchange between the two.
PS! You posted in the wrong section! Hopefully the admins will move it out of this reserved section. (Moved to General)
- www.mql5.com
Thanks for the suggestion. StructToCharArray copies the data and not as performant. It would have been good if we could somehow cast it via pointer address or something similar to that.
Why don't you go with Fernando's suggestion?
Something like this:
struct structure { uint int1; uint int2; uint int3; }; union tobytearray { structure integer; uchar byte[12]; };
Nice to see ways to interchange between struct and uchar[] via Unions.
Would it work for arrays of structs and then arrays of bytes (assume need to use 2 dimensional array, is there a way to have 1 dimensional array in MQL5)?
Why don't you just try it for yourself and see? One learns best by "doing"!
Also, there is something called "documentation" and it is quite extensive and available Online and Offline both in CHM and PDF formats.
There are also numerous Articles as well examples of code in the CodeBase on various things! Run a Search and see what you can find.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use