string to char array?

Alex Parrill via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jun 2 08:53:32 PDT 2015


On Tuesday, 2 June 2015 at 15:07:58 UTC, Kyoji Klyden wrote:
> quick question: What is the most efficient way to covert a 
> string to a char array?

A string is, by definition in D, a character array, specifically 
`immutable(char)[]`. It's not like, for example, Java in which 
it's a completely separate type; you can perform all the standard 
array operations on strings.

If you need to mutate a string, then you can create a mutable 
`char[]` by doing `somestring.dup` as Dennis already mentioned.


More information about the Digitalmars-d-learn mailing list