char[] <--> void*

e-t172 idontlikespam at
Mon Feb 26 09:43:11 PST 2007


(I'm french, sorry for my bad english)

The following doesn't compile :

import std.stdio;

void bar(void* str)
	writefln(cast(char[]) str);

void main()
	char[] foo;

	foo = "Hello world";

	bar(cast(void*) foo);

$ dmd void.d
void.d(5): Error: e2ir: cannot cast from void* to char[]

How should I write it to make it work ?

More information about the Digitalmars-d-learn mailing list