function CountChars(Str:string; car:Char):integer; var Ptr:PChar; begin Result:= 0; Ptr:= PChar(Str); while Ptr^<>#0 do begin if Ptr^=car then Inc(Result); Inc(Ptr); end; end;