Sign in Join
FPDoc Onlineexperiment

AnsiLastChar function

In unit sysutils

Return a pointer to the last character of a string.

Declaration

pascal
function AnsiLastChar(const S: AnsiString): PAnsiChar

Description

This function returns a pointer to the last character of S.

A widestring manager must be installed in order for this function to work correctly with various character sets. If none is installed, this function is the same as @S[Length[S]].

Errors

None.

See also

Example: ex52

pascal
Program Example52;

{ This program demonstrates the AnsiLastChar function }

Uses sysutils;

Var S : AnsiString;
    L : Longint;

Begin
  S:='This is an ansistring.';
  Writeln ('Last character of S is : ',AnsiLastChar(S));
  L:=Longint(AnsiLastChar(S))-Longint(@S[1])+1;
  Writeln ('Length of S is : ',L);
End.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.