Skip to content

Document or fix interaction of scn::prompt and result range() #56

Closed
@dancingbug

Description

@dancingbug

Hi. Modifying the first example given in the README, I have:

#include <scn/scn.h>
#include <cstdio>

int main() {
    int i, j;
    // Read an integer from stdin
    // with an accompanying message
    auto res = scn::prompt("What's your favorite number? ", "{}", i);
    scn::scan(res.range(), "{}", j);
    printf("Oh, cool, %d!\n", i);
    printf("Oh, even cooler, %d!\n", j);
}
// Example invocation:
// What's your favorite number? 345 6789
// Oh, cool, 345!
// Oh, even cooler, 9!

My "678" got eaten unexpectedly!
Please make scnlib give it back, or if this is expected, document obviously the behavior of using range() to scan leftover input from different possible types.

I am using version 1.1

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions