要使用 ReverseString 必須先 uses StrUtils
例如有一字串 "Chameleon"
- var
- str: string;
- begin
- str := 'Chameleon';
- Caption := ReverseString(str);
- end;
執行結果顯示:"noelemahC"
但若是 Delphi 6 之前的版本,則要自己另外寫函式了 ----
- Function String_Reverse(S : String): String;
- var
- i : Integer;
- Begin
- Result := '';
- For i := Length(S) DownTo 1 Do
- Begin
- Result := Result + Copy(S,i,1) ;
- End;
- End;
沒有留言:
張貼留言