//+------------------------------------------------------------------+
//| 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 it: 123
The same variable after applying ZeroMemory() to it: 0
*/
//--- 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]
[0] null 0
[1] null 0
[2] null 0
[3] null 0
*/
}
|