From b33cd35a4414bb8c5f72438ead11bf0f0364f1c0 Mon Sep 17 00:00:00 2001 From: zleyyij <75810274+zleyyij@users.noreply.github.com> Date: Wed, 11 Sep 2024 12:41:34 -0600 Subject: [PATCH] vault backup: 2024-09-11 12:41:34 --- education/software development/ECE1400/C.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/education/software development/ECE1400/C.md b/education/software development/ECE1400/C.md index 5feb293..12c4357 100644 --- a/education/software development/ECE1400/C.md +++ b/education/software development/ECE1400/C.md @@ -72,4 +72,13 @@ printf("You input: %f", v); ### Behavior The validity of a `scanf` call is not necessarily checked at compile time, and so the number of outputs specified should match the number of inputs. -For each formatting specifier specified in the string, `scanf` will attempt to locate an appropriate value in the input, skipping whitespace and newlines if necessary. As `scanf` \ No newline at end of file +For each formatting specifier specified in the string, `scanf` will attempt to locate an appropriate value in the input, skipping whitespace and newlines if necessary until the beginning of a number is reached. + +When asked to read an integer, `scanf` searches for one of: +- A digit +- A plus or minus sign +It will continue to read until it reaches a nondigit (whitespace is not skipped in this case, and it is counted as a nondigit). If it doesn't encounter a valid digit first, it will return early. + +When asked to read a float, `scanf` searches for one of: +- A plus sign or minus sign +- A series of digits (possibly containing a decimal point), followed by an exponent (optional). An exponent consists of the letter `e` or `E` \ No newline at end of file