On Friday, 27 March 2015 at 04:37:34 UTC, jonaspm wrote:
Please, i need your help, I tried this:
write("Write p: ");
readln(p);
p = chomp(p);
writeln("Write q: ");
readln(q);
q = chomp(q);
but the result is:
Write p: Write q:
and doesn't pause to read keyboard input... what's wrong?
Thanks in advance!
The easiest to use is the form "<string> = readln()":
write("Write p: ");
auto p = readln().chomp();
write("Write q: ");
auto q = readln().chomp();
The second version, "<length> = readln(<buffer>)", goes something
like:
auto buf = new char[1024];
write("Write p: ");
string p = buf[0..readln(buf)].chomp().idup;
write("Write q: ");
string q = buf[0..readln(buf)].chomp().idup;
It allows to reuse a preallocated buffer for greater speed and
finer allocation control.
Also worth noting, the best place for such questions in D.learn
group:
http://forum.dlang.org/group/digitalmars.D.learn
Ivan Kazmenko.