Get Character At?

okibi okibi at ratedo.com
Tue Apr 24 09:03:51 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];
> 
> 

Because it isn't working for me. That was what I was trying to do seeing as char[] is simply an array of characters. However, it's returning an int and not a char.


More information about the Digitalmars-d-learn mailing list