Skip to content

StrLen

Length of a null-terminated string.

Declaration

Source position: syspchh.inc line 19

function StrLen(p: PAnsiChar) : SizeInt;  overload; overload;external name 'FPC_PCHAR_LENGTH';
function StrLen(p: PWideChar) : SizeInt;  overload; overload;external name 'FPC_PWIDECHAR_LENGTH';

Description

Returns the length of the null-terminated string P. If P equals Nil then zero (0) is returned.

Errors

None.

See also

Name Description
StrNew Allocate room for new null-terminated string.

Example

Program Example1;

Uses strings;

{ Program to demonstrate the StrLen function. }

Const P : PChar = 'This is a constant pchar string';

begin
  Writeln ('P         : ',p);
  Writeln ('length(P) : ',StrLen(P));
end.