Mark Isaacson:

I'm trying my hand at reading from standard input and having little luck. In particular, I would like to be able to do the rough equivalent of C++'s:

cin >> myString;

There isn't always a 1:1 mapping between C++ and D. In D if you want a single word you usually read the whole line (with a byLine) and then you use split or splitter to take the single words.

Something like this (untested):

foreach (line; stdin.byLine) {
    immutable words = line.chomp.idup.split;
}

Bye,
bearophile

Reply via email to