string to char array?
Alex Parrill via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jun 2 10:03:29 PDT 2015
On Tuesday, 2 June 2015 at 16:41:38 UTC, Kyoji Klyden wrote:
> src:
>
> string source = readText("test.glvert");
>
> const string sources = source.toStringz;
> const int len = source.length;
>
> GLuint vertShader = glCreateShader( GL_VERTEX_SHADER );
>
> glShaderSource(vertShader, 1, &sources, &len);
>
> pt.d(26): Error: cannot implicitly convert expression
> (toStringz(source)) of type immutable(char)* to const(string)
>
> pt.d(34): Error: function pointer glShaderSource (uint, int,
> const(char*)*, const(int)*) is not callable using argument
> types (uint, int, const(string)*, const(int)*)
>
> -
>
> I also tried passing the char array instead but no go.. What am
> I missing? :\
Oops, do `const immutable(char)* sources = source.toStringz` (or
just use `auto sources = ...`).
More information about the Digitalmars-d-learn
mailing list