import std.stdio;
import std.conv;

void main() {
    int i;
    try {
        readf("%d\n", &i); // "a"
    } catch (ConvException e) {
        auto s = readln();
        writeln(s); // "aa", "aaa" or SEGV ???
    }
}

https://wandbox.org/permlink/NMYNjpOgQtfUprBQ

I just want to retry reading if input was invalid. How can I do it?

Reply via email to