Array slicing

Georg Wrede georg.wrede at nospam.org
Thu Dec 14 10:48:38 PST 2006


Heinz wrote:
> Hi, i'm trying to slice an array of chars and print it to the screen but it
> doesn't seems to work, here's the code:
> 
> /////////////////////////////////////
> import std.string;
> 
> alias char[] string;
> 
> int main(char[][] args)
> {
>     printf("hello world\n");
> 	string hw = "Hello_World";
> 	printf(cast(char*)hw[0 .. 5]);
>     return 0;
> }
> 
> /////////////////////////////////////
> 
> What could be wrong? it just prints to the output "Hello_World".
> 
> Heinz

What is wrong is that the hello.d in samples.d STILL USES PRINTF. :-(

That gives you and thousands of others the impression that printf is a 
natural choice for printing stuff in D.


More information about the Digitalmars-d-learn mailing list