digitalmars.D - error in D website demo
- user domain.invalid Feb 05 2008
- Walter Bright <newshound1 digitalmars.com> Feb 05 2008
- "Saaa" <empty needmail.com> Feb 05 2008
- "Saaa" <empty needmail.com> Feb 06 2008
- Moritz Warning <moritzwarning _nospam_web.de> Feb 06 2008
- "Saaa" <empty needmail.com> Feb 06 2008
Hi, I just started playing with D and noticed an error when I build the "Hello World" program on the website at http://www.digitalmars.com/d/2.0/index.html. Such errors are often perplexing to new users :-). Line 23 of the demo is: writefln(cl.argnum, cl.suffix, " arg: %s", cl.argv); But it produces incorrect output: Hello World, Reloaded 1st arg: %sC:\Documents and Settings\DennisC\My Documents\My Source Files\D\hello\hello.exe Notice the %s floating in the output. This is because the library was changed as documented at http://www.digitalmars.com/d/2.0/phobos/std_stdio.html. Its description of writef() says: IMPORTANT: New behavior starting with D 2.006: unlike previous versions, writef (and also writefln) only scans its first string argument for format specifiers, but not subsequent string arguments. This decision was made because the old behavior made it unduly hard to simply print string variables that occasionally embedded percent signs. So it seems to me that this line should be rewritten as either: writefln(cl.argnum, cl.suffix, " arg: ", cl.argv); or writefln("%d%s arg: %s", cl.argnum, cl.suffix, cl.argv); to be compatible with the current library behavior. HTH Dennis Cote
Feb 05 2008
char[] str; char[] str1 = "abc"; str[0] = 'b'; // error, "abc" is read only, may crashAs said a few posts below, this one is wrong as well (as far as I know)
Feb 05 2008
On Wed, 06 Feb 2008 08:29:22 +0100, Saaa wrote:char[] str; char[] str1 = "abc"; str[0] = 'b'; // error, "abc" is read only, may crashAs said a few posts below, this one is wrong as well (as far as I know)
Where do you saw this?
Feb 06 2008
"Moritz Warning" <moritzwarning _nospam_web.de> wrote in message news:foddam$25te$1 digitalmars.com...On Wed, 06 Feb 2008 08:29:22 +0100, Saaa wrote:char[] str; char[] str1 = "abc"; str[0] = 'b'; // error, "abc" is read only, may crashAs said a few posts below, this one is wrong as well (as far as I know)
Where do you saw this?
http://www.digitalmars.com/d/1.0/arrays.html special array types
Feb 06 2008









"Saaa" <empty needmail.com> 