Hello. How can I retrieve a particular character from a string?
For example, in English, I will specify:
set PHRASE as 'Pascal Programming'
get the fifth character from PHRASE
then the result should be A because the fifth character is an A.
How can I 'translate' this into Pascal? Thanks.
Comments
:
: For example, in English, I will specify:
:
: set PHRASE as 'Pascal Programming'
: get the fifth character from PHRASE
:
: then the result should be A because the fifth character is an A.
:
: How can I 'translate' this into Pascal? Thanks.
:
A string is an 1-indexed array of chars. This means that you can get a the i-th character from string S using the following code:
[code]
ch := S[i];
[/code]
in your case it would be:
[code]
ch := Phrase[5];
[/code]
: :
: : For example, in English, I will specify:
: :
: : set PHRASE as 'Pascal Programming'
: : get the fifth character from PHRASE
: :
: : then the result should be A because the fifth character is an A.
: :
: : How can I 'translate' this into Pascal? Thanks.
: :
: A string is an 1-indexed array of chars. This means that you can get a the i-th character from string S using the following code:
: [code]
: ch := S[i];
: [/code]
: in your case it would be:
: [code]
: ch := Phrase[5];
: [/code]
:
I see. Thanks very much!