]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
scanf.3: BUGS: It's impossible to know how many characters were consumed
authorAlejandro Colomar <alx@kernel.org>
Sat, 9 Dec 2023 12:35:19 +0000 (13:35 +0100)
committerAlejandro Colomar <alx@kernel.org>
Sat, 9 Dec 2023 12:35:33 +0000 (13:35 +0100)
Suggested-by: Zack Weinberg <zack@owlfolio.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
man3/scanf.3

index 63f9c6dfd70c34f303faa9b9d7b571c4834ddf7f..be335a5974ccd71b898913ff344c1288ff2ee696 100644 (file)
@@ -144,6 +144,15 @@ like the standard input stream.
 .P
 These functions can't report errors after the last
 non-suppressed conversion specification.
+.SH BUGS
+It is impossible to accurately know
+how many characters these functions have consumed from the input stream,
+since they only report the number of successful conversions.
+For example,
+if the input is "123\en\ a",
+.I scanf(\[dq]%d\ %d\[dq], &a, &b)
+will consume the digits, the newline, and the space, but not the letter a.
+This makes it difficult to recover from invalid input.
 .SH SEE ALSO
 .BR fgets (3),
 .BR getline (3),