//+------------------------------------------------------------------+
//| 脚本程序起始函数 |
//+------------------------------------------------------------------+
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,"'");
/*
结果:
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);
/*
结果:
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);
/*
结果:
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);
/*
结果:
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
*/
}
|