From RAD Studio API Documentation
Jump to: navigation, search


procedure FillChar(var X; Count: NativeInt; Value: Integer);


Type Visibility Source Unit Parent
procedure public System.pas System System


Fills contiguous bytes with a specified value.

In Delphi, FillChar fills Count contiguous bytes (referenced by X) with the value specified by Value (Value can be of type Byte or AnsiChar)

Note that if X is a UnicodeString, this may not work as expected, because FillChar expects a byte count, which is not the same as the character count.

In addition, the filling character is a single-byte character. Therefore, when Buf is a UnicodeString, the code FillChar(Buf, Length(Buf), #9); fills Buf with the code point $0909, not $09. In such cases, you should use the StringOfChar routine.

Warning: This function does not perform any range checking.

Warning: This method has an untyped parameter, which can lead to memory corruption. To avoid this problem, use SizeOf to find the number of bytes appropriate to fill for the data type of the X parameter.

See Also

Code Examples