Sign in Join
FPDoc Onlineexperiment

strpos function

In unit sysutils

Find position of one null-terminated substring in another.

Declaration

pascal
function StrPos(str1: PAnsiChar; str2: PAnsiChar): PAnsiChar

Description

Returns a pointer to the first occurrence of S2 in S1. If S2 does not occur in S1, returns Nil.

Errors

None.

See also

Example: ex15

pascal
Program Example15;

Uses strings;

{ Program to demonstrate the StrPos function. }

Const P : PChar = 'This is a PChar string.';
      S : Pchar = 'is';
begin
  Writeln ('Position of ''is'' in P : ',sizeint(StrPos(P,S))-sizeint(P));
end.

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