Delphi/Lazarus: Convert String to Char
Question by Guest | Last update on 2022-12-07 | Created on 2018-01-02
I have a string that I would like to convert to a char, because I can only pass it to a function in this format.
Although my string only consists of a single letter, which actually corresponds to a char, the function does not accept my input. Is there any way to change the string to a variable of the type Char? Something like c := s ist not possible and results in an error message.
Related Topics
Delphi/Lazarus: Only allow Numbers in TEdit
Tip | 0 Comments
PHP: Check Strings with Ctype-Functions for Character Classes
Article | 0 Comments
MySQL: Line breaks in MySQL
Tip | 0 Comments
Delphi/Lazarus: Display current Date and Time
Tip | 0 Comments
Delphi/Lazarus: 3 Ways to round a Number to X Decimal Places
Tutorial | 7 Comments
Delphi/Lazarus: How to set up a Link to a Website in an Application
Tutorial | 0 Comments
Delphi/Lazarus: Show Byte Array as String of HEX Values
Tip | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
Similar to an array, you can also access the individual parts of a string.
So for example:
Here you have a string with the content "A", which we convert to a char with the content "A".
With s[i] you get the letter at the corresponding position i of s. s[1] would be the first letter of s, because unlike an array, the counting of a string does not begin at 0 but starts with 1.
Last update on 2022-12-07 | Created on 2018-01-02