From 1bd69ff2e45a819485e029c83e1a95167509ca55 Mon Sep 17 00:00:00 2001 From: BBaoVanC Date: Wed, 21 Oct 2020 20:20:52 -0500 Subject: [PATCH] letter-grade.c: Change scanf usage to fgets --- letter-grade.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/letter-grade.c b/letter-grade.c index 7123716..69f8527 100644 --- a/letter-grade.c +++ b/letter-grade.c @@ -1,9 +1,13 @@ #include +#include int main() { - int input; - scanf("%i", &input); - printf("Your input was: %i\n", input); + char inputText[4]; + fgets(inputText, 4, stdin); + printf("inputText: %s\n", inputText); + long int input; + input = strtol(inputText, NULL, 0); + printf("input: %i\n", input); if ((input >= 0) && (input <= 100)) { char letter; @@ -35,4 +39,4 @@ int main() { } return 0; -} \ No newline at end of file +}