From 485f9e10562a393b197e864f123787aaa5bfefca Mon Sep 17 00:00:00 2001 From: Oleksandr Hryshchenko Date: Thu, 1 Apr 2021 13:20:25 +0000 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20'du4/program.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit vv --- du4/program.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/du4/program.c b/du4/program.c index 4bc46de..10e0b95 100644 --- a/du4/program.c +++ b/du4/program.c @@ -15,17 +15,19 @@ int main(){ char* ptr; bool equals = false; - for(int i = 0; fgets(input, 100, stdin); i++){ + for(int i = 0; fgets(input, 100, stdin) != NULL; i++){ counter = 0; operation = 0; equals = false; memset(number1, '\0', 25); memset(number2, '\0', 25); - while (input[counter] != '\0'){ + while (input[counter] != '\0' && input[counter] != '\n'){ symbol = input[counter++]; while(isspace(symbol)) symbol = input[counter++]; + if(symbol == '\0' || symbol == '\n') + break; switch(symbol){ case '+': operation = 1;