Problems with MemoryStream

Tobias Pankrath tobias at pankrath.net
Sat Jan 22 14:32:18 PST 2011


Hello,

I just got my hands on a copy of TDPL and I like the book and D is very
promising. But I run into problems with the easiest of program. I just
want to write to and from a stream, just the way it is possible with
C++ stringstreams. But this program produces an empty line as 
output.

/** begin program
import std.stdio;
import std.stream;

void main() {
  auto stream = new MemoryStream( );
  string s = "this is a line";
 
  stream.writeLine(s);
  char[] get = stream.readLine();
  writeln(get);
}
 
// end of program

Why? Whats the right way to do it?

Greetings, Tobias
 


More information about the Digitalmars-d-learn mailing list