basic interactive readf from stdin

Jay Norwood via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Dec 26 11:40:59 PST 2015


Simple VS console app in D.  Reading lines to a string variable 
interactively. Object is to have no extra blank lines in the 
console output.  Seems very broken for this use, requiring two 
extra "enter" entries before the outputs both appear. Version 
DMD32 D Compiler v2.069.2

import std.stdio;

int main(string[] argv)
{
  string nm;
  stdin.readf("%s\n",&nm);
  writeln("nm:",nm);
  stdin.readf("%s\n",&nm);
  writeln("nm:",nm);
  return 0;
}

======== io shown below
123
456
nm:123

nm:456



More information about the Digitalmars-d-learn mailing list