[fpc-pascal] Array initialization

Fantomas fantomaspda at yandex.com
Wed Mar 18 01:25:26 CET 2009


Hello, Francisco!

Wednesday, March 18, 2009, 2:50:21 AM, you wrote:

> Is a loop the only way to initialize all the values in an array other than
> Values: array[1..2] of integer = (0,0);

> In the program I am working on, Values will be an array of 128 integers and 
> I would like to initialize them to 0.

> Right now I just using:
> for InitialLoop := 1 to 128 do
>         Values[InitialLoop] :=0;

As far as I know, global variables are initialised with zeros when an
application starts. But to ensure your array is filled with zeros you can use
FillChar:

FillChar(Values,SizeOf(Values),0)

--
Best regards,
Fantomas




More information about the fpc-pascal mailing list