segunda-feira, 21 de setembro de 2009

Contador de letras

Function WordsCount( s : string ) : integer;
var
ps: PChar;
nSpaces,n : integer;
begin
n := 0;
s := s + #0;
ps := @s[ 1 ];
while( #0 <> ps^ ) do
begin
while((' ' = ps^)and(#0 <> ps^)) do
begin
inc( ps );
end;
nSpaces := 0;
while((' ' <> ps^)and(#0 <> ps^))do
begin
inc(nSpaces);
inc(ps);
end;
if ( nSpaces > 0 ) then
begin
inc( n );
end;
end;
Result := n;
end;

Nenhum comentário:

Postar um comentário