[fpc-pascal] FillWord with dynamics array.

Jonas Maebe jonas.maebe at elis.ugent.be
Fri May 27 00:01:47 CEST 2011


On 26 May 2011, at 23:18, Luis Fernando Del Aguila Mejía wrote:

> How fill of the same value a dynamic array?
> 
> {$codepage utf8}
> Var A,B:array of word;
>      i:integer;
> Begin
>  SetLength(A,10);
>  SetLength(B,10);
> 
>  FillWord(A[0],2*10,0);  //when value diferent to zero, no runtime error

FillWord fills per word (= 16 bit). So you are filling 2*10 = 20 words, while you only allocated 10. Use fillchar if you want to specify the number of bytes.


Jonas


More information about the fpc-pascal mailing list