readln() doesn't stop to read the input.

lobo via Digitalmars-d digitalmars-d at puremagic.com
Thu Mar 26 23:03:00 PDT 2015


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!

This works for me on Linux:
---

import std.stdio;
import std.string;
void main()
{
     char[] p, q;
     p.length=1024;
     q.length=1024;

     write("Write p: ");
     readln(p);
     p=p.chomp;

     write("Write q: ");
     readln(q);
     q=q.chomp;

     writeln; writefln("p=%s, q=%s", p,q);
}
---

bye,
lobo


More information about the Digitalmars-d mailing list