String convention

Jarrett Billingsley kb3ctd2 at yahoo.com
Sat Jul 1 13:58:27 PDT 2006


"Niklas Ulvinge" <Niklas_member at pathlink.com> wrote in message 
news:e86km2$12ar$1 at digitaldaemon.com...

> This has a limitation, strings can't be longer than 'data' allows.
> Is there a way around this?

Keep in mind that the "length" member of an array is the word size of the 
machine, so that the longest array possible would take up the entire memory 
space :S

> printf("%s",s);

Never ever ever ever use printf() in D.  Please.  The spec uses it 
profusely, but that's because a lot of the examples were written before 
std.stdio.writefln() was written.  Use that instead.  You don't even have to 
have a format string with writefln, i.e.

import std.stdio;

...

char[] s = "hi";
writefln(s);
writefln(4, ", ", 5);
writefln("hello"); 





More information about the Digitalmars-d mailing list