string to char array?

Kyoji Klyden via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jun 2 10:14:33 PDT 2015


On Tuesday, 2 June 2015 at 17:03:32 UTC, Alex Parrill wrote:
> 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 = ...`).

OMG IT FINALLY WORKS :O
(%1 of the program complete!)

Thankyou very much, this was a huge help! It's such a small piece 
but I feel like a learned alot from this. :)


More information about the Digitalmars-d-learn mailing list