How to reverse strings
Although reversing characters in a string is not a difficult task, it's always nice to have a ready made function to do that. How about something like the following:
function ReverseString( s : string )
: string;
var
i : integer;
s2 : string;
begin
s2 := '';
for i := 1 to Length( s ) do
begin
s2 := s[ i ] + s2;
end;
Result := s2;
end;
Listing #1 : Delphi code. Download
revstr (0.26 KB).
Applicable Keywords : Delphi, Delphi 1.x, Delphi 2.x, Delphi 3.x, Functions