diff --git a/a1/program.c b/a1/program.c index 6aac6d0..5531d3c 100644 --- a/a1/program.c +++ b/a1/program.c @@ -10,7 +10,7 @@ void check_brackets(const char *code) { char stack[100]; int top = -1; - printf("Read: %s", code); // Výstup pre načítanie vstupu + printf("Read: %s\n", code); for (int i = 0; code[i] != '\0'; i++) { char c = code[i]; @@ -38,6 +38,11 @@ void check_brackets(const char *code) { int main() { char code[100]; if (fgets(code, sizeof(code), stdin) != NULL) { + + size_t len = strlen(code); + if (len > 0 && code[len - 1] == '\n') { + code[len - 1] = '\0'; + } check_brackets(code); } return 0;