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;