Files
mql5-skills/skills/mql5/references/docs/34-standardlibrary/1728-standardlibrary-datastructures-carraystring-carraystringassignarrayconst.md
T
2026-06-23 21:47:51 +08:00

65 lines
1.3 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# AssignArray
Copies the elements of one array to another.
```
bool  AssignArray(
   const CArrayString*  src      // pointer to the source
   )
```
Parameters
src
[in] Pointer to an instance of the CArrayString class used as a source of elements to copy.
Return Value
true - successful, false - cannot copy the elements.
Example:
```
//--- example for CArrayString::AssignArray(const CArrayString*)
#include <Arrays\ArrayString.mqh>
//---
void OnStart()
  {
   CArrayString *array=new CArrayString;
   //---
   if(array==NULL)
     {
      printf("Object create error");
      return;
     }
   //--- create source array
   CArrayString *src  =new CArrayString;
   if(src==NULL)
     {
      printf("Object create error");
      delete array;
      return;
     }
   //--- add source arrays elements
   //--- . . .
   //--- assign another array
   if(!array.AssignArray(src))
     {
      printf("Array assigned error");
      delete src;
      delete array;
      return;
     }
   //--- arrays is identical
   //--- delete source array
   delete src;
   //--- use array
   //--- . . .
   //--- delete array
   delete array;
  }
```