Reading by character and by line from stdin
Trass3r
un at known.com
Thu Aug 25 15:08:22 PDT 2011
> I'd like to know how to read from stdin one character at a time, read
> with whitespace as a delimiter, and read line by line.
A nifty way of reading by byte is the undocumented (only the writer is
documented):
import std.stdio;
void main()
{
foreach(c; LockingTextReader(stdin))
....
}
by line is
foreach(c; stdin.byLine)
and you should also be able to abuse the function to split by whitespace:
http://d-programming-language.org/phobos/std_stdio.html#ByLine
See the terminator parameter.
More information about the Digitalmars-d-learn
mailing list