Doubled newlines
dcoder
dcoder at devnull.com
Tue Aug 3 12:36:23 PDT 2010
== Quote from bearophile (bearophileHUGS at lycos.com)'s article
> I think there is a bug here, but can you please try it a bit?
> The name of this program is "test.d", so it loads its souce code:
> import std.file: readText;
> import std.stdio: write;
> void main() {
> string s = readText("test.d");
> write(s);
> }
> On windows the output is:
> import std.file: readText;
> import std.stdio: write;
> void main() {
> string s = readText("test.d");
> write(s);
> }
> So it shows extra newlines (on Windows newlines are two chars).
> On Windows a similar Python program doesn't show the doubled newlines:
> s = open("test.d").read()
> print s
> Bye,
> bearophile
By the way, your code works correctly on my computer. I ran the program in cygwin
using a bash shell under Windows XP. What doesn't work correctly in this setup is
writef() followed by user input. I need to add stdout.flush() after writef.
So go figure...
$ dmd --help
Digital Mars D Compiler v2.047
Copyright (c) 1999-2010 by Digital Mars written by Walter Bright
Documentation: http://www.digitalmars.com/d/2.0/index.html
$ ./readlines.exe
import std.file: readText;
import std.stdio: write;
void main() {
string s = readText( "readlines.d");
write(s);
}
More information about the Digitalmars-d-learn
mailing list