Get Character At?

Clay Smith clayasaurus at gmail.com
Tue Apr 24 09:37:24 PDT 2007


Tomas Lindquist Olsen wrote:
> okibi wrote:
> 
>> Derek Parnell Wrote:
>>
>>> On Tue, 24 Apr 2007 10:30:16 -0400, okibi wrote:
>>>
>>>> Is there a getCharAt() function for D?
>>> Get a character from what? A string, a file, a console screen, ... ?
>>>
>>> --
>>> Derek Parnell
>>> Melbourne, Australia
>>> "Justice for David Hicks!"
>>> skype: derek.j.parnell
>> Such as this:
>>
>> char[] text = "This is a test sentence.";
>>
>> int loc = 5;
>>
>> char num5 = text.getCharAt(loc);
>>
>> Something along those lines.
> 
> Why not just do:
> 
> char[] text = "some text";
> char num5 = text[5];
> 

text[5] will return the sixth element in the array.


More information about the Digitalmars-d-learn mailing list