ZeroMemory

이 함수는 참조로 전달된 변수를 재설정.

void  ZeroMemory(
   void & variable      // 변수를 재설정
   );

매개변수

변수

[in] [out]  참조로 전달된 변수를 재설정합니다(영점 값으로 초기화)

값 반환

반환 값 없음.

주의

함수 매개변수가 문자열인 경우 호출은 NULL을 값으로 표시하는 것과 같습니다.
단순 유형 및 해당 문자열뿐 아니라 이러한 유형으로 구성된 구조/클래스의 경우 이는 간단한 재설정입니다.
문자열과 동적 문자열을 포함하는 개체의 경우 각 요소에 대해 ZeroMemory()가 호출됩니다.
수식어로 보호되지 않는 문자열의 경우 이는 모든 요소의 영점 조정입니다.
복잡한 개체 문자열의 경우 각 요소에 대해 ZeroMemory()가 호출됩니다.

ZeroMemory()는 보호된 멤버 또는 계승이 있는 클래스에 적용할 수 없습니다.

예:

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- 문자열 선언 및 초기화
   string str="Test ZeroMemory func";
//--- ZeroMemory()를 적용하기 전에 로그에 행을 보냅니다.
   PrintFormat("The line before applying ZeroMemory() to it: '%s'",str);
//--- 문자열을 재설정하고 결과를 로그로 보냅니다.
   ZeroMemory(str);
   Print("The same line after applying ZeroMemory() to it: '",str,"'");
  /*
   Result:
   The line before applying ZeroMemory() to it: 'Test ZeroMemory func'
   The same line after applying ZeroMemory() to it: ''
  */
 
//--- int형 변수 선언 및 초기화
   int var=123;
//--- ZeroMemory()를 적용하기 전에 로그에 행을 보냅니다.
   PrintFormat("\nThe integer variable before applying ZeroMemory() to it: %d",var);
//--- 변수를 재설정하고 결과를 로그에 보냅니다.
   ZeroMemory(var);
   PrintFormat("The same variable after applying ZeroMemory() to it: %d",var);
  /*
   Result:
   The integer variable before applying ZeroMemory() to it123
   The same variable after applying ZeroMemory() to it0
  */
 
//--- int형 배열을 선언하고 초기화합니다.
   int arr[]={0,1,2,3,4,5,6,7,8,9};
//--- ZeroMemory()를 적용하기 전에 배열을 로그로 보냅니다.
   Print("\nThe integer array before applying ZeroMemory() to it:");
   ArrayPrint(arr);
//--- 배열을 재설정하고 결과를 로그에 보냅니다.
   ZeroMemory(arr);
   Print("The same array after applying ZeroMemory() to it:");
   ArrayPrint(arr);
  /*
   Result:
   The integer array before applying ZeroMemory() to it:
   0 1 2 3 4 5 6 7 8 9
   The same array after applying ZeroMemory() to it:
   0 0 0 0 0 0 0 0 0 0
  */
 
//--- 두 필드(문자열 및 정수 필드)의 구조를 선언합니다.
   struct STest
     {
      string   var_string;
      long     var_long;
     };
//--- STest 구조 유형의 배열을 선언하고 초기화합니다.
   STest arr_struct[]={ {"0",0}, {"1",1}, {"2",2}, {"3",3} };
//--- ZeroMemory()를 적용하기 전에 배열을 로그로 보냅니다.
   Print("\nThe array struct before applying ZeroMemory() to it:");
   ArrayPrint(arr_struct);
//--- 구조 배열을 재설정하고 결과를 로그로 보냅니다.
   ZeroMemory(arr_struct);
   Print("The same array struct after applying ZeroMemory() to it:");
   ArrayPrint(arr_struct);
  /*
   Result:
   The array struct before applying ZeroMemory() to it:
       [var_string] [var_long]
   [0"0"                   0
   [1"1"                   1
   [2"2"                   2
   [3"3"                   3
   The same array struct after applying ZeroMemory() to it:
       [var_string] [var_long]
   [0null                  0
   [1null                  0
   [2null                  0
   [3null                  0
  */
  }