Parsing a string from stdin using formattedRead

Mark smarksc at gmail.com
Wed Dec 6 18:47:03 UTC 2017


std.format has the function formattedRead which can be used to 
parse a string, e.g.

string first_name;
string last_name;
string info = readln();
formattedRead(info, "%s %s", first_name, last_name);

This piece of code works as intended. However, since I don't need 
the input after it's parsed, I wanted to omit the 3rd line of 
code above and replace the 4th line with

formattedRead(readln(), "%s %s", first_name, last_name);

But this raises a compilation error, claiming that formattedRead 
"cannot deduce function from argument types". What's the problem 
here?


More information about the Digitalmars-d-learn mailing list