scanf for strings stops at whitespace. readf does not.
This shouldn't be too much of a problem, because the %s could be followed by something else, and that match would eagerly go to the next thing.
But for a trailing %s, with a string as the target, the result is that string is filled with the *rest of the stream*. That makes no sense, and is a land mine for people who aren't familiar with readf. Not only that, but using readf to consume the rest of the file into a string doesn't seem like a great use case to support.
I propose that readf, when presented with a format that ends in %s, and whose matching type is a string, should stop when a whitespace character is encountered.
I know this is an inconsistency and special case. It could be done potentially in a way to avoid special cases (like send to the processing function a boolean saying nothing is left in the format string), but it should be done this way.
Alternatively, this could be considered a runtime error.
Comment #1 by robert.schadek — 2024-12-01T16:41:50Z