On Tuesday, 2 June 2015 at 15:53:33 UTC, Alex Parrill wrote:
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.

The problem I was having was actually that an opengl function (specifically glShaderSource) wouldn't accept strings. I'm still can't get it to work actually :P

glShaderSource (uint, int, const(char*)*, const(int)*)

This one function is a bugger, been going at this for hours.


On Tuesday, 2 June 2015 at 15:38:24 UTC, Meta wrote:

Note that this will allocate a new garbage collected array.

Thx for the heads up

Reply via email to