SystemFillChar (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example fills a char array with characters and then assigns the array to a text edit.

Code

procedure TForm1.Button1Click(Sender: TObject);
var
  S: array[0..79] of AnsiChar;
begin
  { Set to all Xs }
  FillChar(S, SizeOf(S), Ord('X'));
  Edit1.Text := S;
end;

Note: System.FillChar should be used with great care because untyped parameters can be the source of memory corruption.To avoid this problem, use SizeOf to find the number of bytes appropriate to fill for the data type of the first parameter.

Uses