[Issue 4656] stdio.readf does not ignore white space

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon May 9 09:22:02 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=4656



--- Comment #1 from Andrei Alexandrescu <andrei at metalanguage.com> 2011-05-09 09:18:02 PDT ---
This is by design. The example works when modified as follows:

import std.stdio;

void main()
{
    int i, j;
    readf("%s", &i);
    readf(" %s", &j);
}

The space before the second parameter tells readf to read and skip all
whitespace before attempting conversion.

I've implemented readf to be a fair amount more Nazi about whitespace than
scanf in an attempt to improve its precision. Scanf has been famously difficult
to use for complex input parsing and validation, and I attribute some of that
to its laissez-faire attitude toward whitespace. I'd be glad to relax some of
readf's insistence on precise whitespace handling if there's enough evidence
that that serves most of our users. I personally believe that the current
behavior (strict by default, easy to relax) is best.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list