Mega Code Archive

 
Categories / Delphi / Examples
 

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;