Get Character At?

Tomas Lindquist Olsen tomas at famolsen.dk
Tue Apr 24 09:11:37 PDT 2007


okibi wrote:
>> 
>> 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.

import std.stdio;

void main()
{
    char[] text = "this is a sentence";
    int loc = 5;
    writefln("%s", typeid(typeof(text[loc])));
}

this prints 'char' as expected...


More information about the Digitalmars-d-learn mailing list