char[] <--> void*

e-t172 idontlikespam at nospam.com
Mon Feb 26 10:32:10 PST 2007


Frits van Bommel a écrit :
> Arrays need a length, which you could also pass separately:
> ---
> import std.stdio;
> 
> void bar(size_t length, void* str)
> {
>     writefln((cast(char*) str)[0 .. length]);
> }
> 
> void main()
> {
>     char[] foo;
> 
>     foo = "Hello world";
> 
>     bar(foo.length, cast(void*) foo);
> }
> ---

Thanks :)


More information about the Digitalmars-d-learn mailing list