digitalmars.D - error in D website demo
- user domain.invalid (28/28) Feb 05 2008 Hi,
- Walter Bright (1/1) Feb 05 2008 Thanks. Fixed.
- Saaa (4/4) Feb 05 2008 char[] str;
- Saaa (1/1) Feb 06 2008 I love monologues :/
- Moritz Warning (2/6) Feb 06 2008 Where do you saw this?
- Saaa (4/10) Feb 06 2008 http://www.digitalmars.com/d/1.0/arrays.html
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:http://www.digitalmars.com/d/1.0/arrays.html special array typeschar[] 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