www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20392] New: formattedRead: %*d and %d should read the same

https://issues.dlang.org/show_bug.cgi?id=20392

          Issue ID: 20392
           Summary: formattedRead: %*d and %d should read the same
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: bugzilla d-ecke.de

This throws an exception:

---
import std.format;

void main()
{
    string str = "foo bar buzz";
    string a, c;
    int b;
    formattedRead(str, "%s %d %s", &a, &b, &c);
}
---

This not:

---
import std.format;

void main()
{
    string str = "foo bar buzz";
    string a, c;
    formattedRead(str, "%s %*d %s", &a, &c);
}
---

The reason is, that %*d accepts an empty string as a number while %d doesn't.

--
Nov 14 2019