scanf(str,&b) public

The trick here is doing a match where you grab one line of input at a time. The linebreak may or may not occur at the boundary where the string matches a format specifier. And if it does, some rule about whitespace may or may not be in effect…

That’s why this is much more elaborate than the string version.

For each line: Match succeeds (non-emptily) and the last attempted spec/string sub-match succeeded:

could the last spec keep matching?
  yes: save interim results and continue (next line)

The last attempted spec/string did not match:

are we on the next-to-last spec in the string?

yes:
  is fmt_string.string_left all spaces?
    yes: does current spec care about input space?
      yes: fatal failure
      no: save interim results and continue
no: continue  [this state could be analyzed further]
Show source
Register or log in to add new notes.