string, char[], overloaded functions.

dajones via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Nov 2 16:38:56 PST 2014


"Adam D. Ruppe" <destructionator at gmail.com> wrote in message 
news:xxnfghisussknbqzvopt at forum.dlang.org...
> On Friday, 31 October 2014 at 23:59:54 UTC, dajones wrote:
>> So shouldnt char[] implicity convert to string
>
> Nope, char[] casting to string is generally a bad thing that should be 
> avoided because it can leave you with a mutable string, which isn't 
> supposed to happen.
>
> In your case, why are you using char[] for the buf instead of just string?

I was using stdin.readln to read input from the console, and that takes a 
char[] buffer. At least the example code on dlang.org reads into a char[] 
buffer.

I want to coble together that char[] input with some string literals. I was 
writing a key to the registry like this...

key.setValue("keyname", buf~"Foo");

but it kept saying it couldnt match setValue(string, int), which is one f 
the other overloads.

Thanks,

Chris





More information about the Digitalmars-d-learn mailing list