BB-8:
Or does MQL5 returns string by value? Then it will make a copy of dynamicArray[0] before returning.
yes
Thanks for the answers.
I find the return by value confusing when using a string (because in C a string is a char* ; or it can be std::string in C++). In this case it is an array of strings to complicate further.
Even in C ++ it is confusing because "String literals are the only literals that are lvalues and have static storage duration"

C++ pointer to objects which go out of scope when function returns - why does this work?
- 2013.05.16
- Angus Comber Angus Comber 7,720 9 9 gold badges 46 46 silver badges 88 88 bronze badges
- stackoverflow.com
Both these calls to get_string and get_string2 return objects which go out of scope when the function returns. Shouldn't the returned object be an address in memory which goes out of scope after the function returns? This is using Visual Studio 2008. Should this always work? Why?
William Roeder:
Who deleted my comment? He's always correcting people, and here, he's misleading the OP. It's 'irrelevant'. https://www.spellchecker.net/misspellings/irrevalent
You returned a copy of the element. The array is irrevalent.
Anonymous3 Geek:
Who deleted my comment? He's always correcting people, and here, he's misleading the OP. It's 'irrelevant'. https://www.spellchecker.net/misspellings/irrevalent
Who deleted my comment? He's always correcting people, and here, he's misleading the OP. It's 'irrelevant'. https://www.spellchecker.net/misspellings/irrevalent
I deleted your irrelevant comment -
Forum on trading, automated trading systems and testing trading strategies
...
Anonymous3 Geek, 2020.10.23 09:00
@whroeder1 The word is irrelevant.if not - your irrelevant/flooding comments will be deleted and you will be banned.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
According to the documentation: "Dynamic arrays are automatically freed when going beyond the visibility area of the block they are declared in."
For example:
So "dynamicArray" will be deallocated when the function returns. But what occurs to the memory of dynamicArray[0] ? It should not be deallocated if used outside the function.
Or does MQL5 returns string by value? Then it will make a copy of dynamicArray[0] before returning.