//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//--- declaramos e incializamos la línea
string str="Test ZeroMemory func";
//--- mostramos en el diario la línea hasta la aplicación a la misma de ZeroMemory()
PrintFormat("The line before applying ZeroMemory() to it: '%s'",str);
//--- ponemos a cero la línea y registramos el resultado
ZeroMemory(str);
Print("The same line after applying ZeroMemory() to it: '",str,"'");
/*
Resultado:
The line before applying ZeroMemory() to it: 'Test ZeroMemory func'
The same line after applying ZeroMemory() to it: ''
*/
//--- declaramos e inicializamos la variable con el tipo int
int var=123;
//--- mostramos en el diario la línea hasta la aplicación a la misma de ZeroMemory()
PrintFormat("\nThe integer variable before applying ZeroMemory() to it: %d",var);
//--- ponemos a cero la variable y mostramos el resultado en el diario
ZeroMemory(var);
PrintFormat("The same variable after applying ZeroMemory() to it: %d",var);
/*
Resultado:
The integer variable before applying ZeroMemory() to it: 123
The same variable after applying ZeroMemory() to it: 0
*/
//--- declaramos e inicializamos el array con el tipo int
int arr[]={0,1,2,3,4,5,6,7,8,9};
//--- mostramos en el diario el array hasta la aplicación al mismo de ZeroMemory()
Print("\nThe integer array before applying ZeroMemory() to it:");
ArrayPrint(arr);
//--- ponemos a cero el array y mostramos el resultado en el diario
ZeroMemory(arr);
Print("The same array after applying ZeroMemory() to it:");
ArrayPrint(arr);
/*
Resultado:
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
*/
//--- declaramos una estructura de dos campos: de tipo string y entero
struct STest
{
string var_string;
long var_long;
};
//--- declaramos e inicializamos un array con el tipo de estructura STest
STest arr_struct[]={ {"0",0}, {"1",1}, {"2",2}, {"3",3} };
//--- mostramos en el diario el array de estructuras hasta la aplicación al mismo de ZeroMemory()
Print("\nThe array struct before applying ZeroMemory() to it:");
ArrayPrint(arr_struct);
//--- ponemos a cero el array de estructuras y mostramos el resultado en el diario
ZeroMemory(arr_struct);
Print("The same array struct after applying ZeroMemory() to it:");
ArrayPrint(arr_struct);
/*
Resultado:
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
*/
}
|