Formatted read of tokens?

Jerry via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jun 17 00:07:25 PDT 2014


Hi all,

I'm porting some C++ code into D that uses istream to read lines like

label 3

where there can spaces or tabs between the 2 fields.  In c++, this is:

string l;
int i;
istr >> l >> i;

What's the equivalent in D?  It appears that D formatted read for
strings grabs everything up to a newline and doesn't support whitespace
tokenization.

If I do

f.readf("%s %s", &l, &i);

it fails if the whitespace is a tab.

Thanks
Jerry


More information about the Digitalmars-d-learn mailing list