i have been trying (unsuccessfully) to get the last character of a string using STRLEN. The string is a postcode(UK) which consists of numbers and chars. How do i get delphi to read the string backwards. I am using delphi 2.0.
You people confusing pascal with c, there is no strlen(string) in pascal, but length(string) which returns you the length of the string. To read backwards,
for i:=length(_string_) downto 1 do
write(_string_);
and if you have s:='hello'; _char_:=s[5] gives 'o';
Best Regards,
As Aphrodita mentioned, in Pascal,
MyChar := Copy(MyString, Length(MyString), 1)
returns the last character in MyString. If this
is not working, you may have hidden characters
which should be removed first as in:
MyChar := Copy(Trim(MyString), Length(MyString), 1)
If doing this in C/C++, remember that Pascal String
has first character at [1], not [0].
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.