From 9624010c7becce73fd8e9a45d26106400b9b5b6f Mon Sep 17 00:00:00 2001 From: VIliam Date: Thu, 31 Oct 2024 23:48:30 +0100 Subject: [PATCH] s --- a1/program.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/a1/program.c b/a1/program.c index 1f63316..5531d3c 100644 --- a/a1/program.c +++ b/a1/program.c @@ -10,8 +10,7 @@ void check_brackets(const char *code) { char stack[100]; int top = -1; - // Výpis pre načítaný kód - printf("Read: %s\n", code); + printf("Read: %s\n", code); for (int i = 0; code[i] != '\0'; i++) { char c = code[i]; @@ -19,11 +18,11 @@ void check_brackets(const char *code) { stack[++top] = c; } else if (c == '}' || c == ']' || c == ')' || c == '>') { if (top == -1) { - fprintf(stderr, "Unexpected closing bracket %c in %d\n", c, i); + printf("Unexpected closing bracket %c in %d\n", c, i); return; } if (!match(stack[top], c)) { - fprintf(stderr, "Crossed bracket %c in %d, expected %c\n", c, i, stack[top]); + printf("Crossed bracket %c in %d, expected %c\n", c, i, stack[top]); return; } top--; @@ -32,14 +31,14 @@ void check_brackets(const char *code) { if (top == -1) { printf("All brackets OK\n"); } else { - fprintf(stderr, "Missing closing brackets: %c\n", stack[top]); + printf("Missing closing brackets: %c\n", stack[top]); } } int main() { char code[100]; if (fgets(code, sizeof(code), stdin) != NULL) { - // Odstráň nový riadok, ak existuje + size_t len = strlen(code); if (len > 0 && code[len - 1] == '\n') { code[len - 1] = '\0';