eliaskosunen/scnlib

Support for max number of characters in string format specifier

Closed this issue · 1 comments

I'm trying to port this scanf format specifier:
"%3s-%u"
How can I limit the number of characters the string format specifier will accept?

A similar issue with integers:
"%2hu"

Now supported:

std::string str;
// Read max 3 chars
auto result = scn::scan("abcde", "{:3}", str);
// str == "abc"
// result.range() == "de"

// Same for ints
int i;
result = scn::scan("12345", "{:3}", i);
// i == 123
// result.range() == "45"