This commit is contained in:
Džubara 2024-10-31 23:45:27 +01:00
parent e2ae3d2773
commit 1d86789433

View File

@ -10,7 +10,7 @@ void check_brackets(const char *code) {
char stack[100]; char stack[100];
int top = -1; 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++) { for (int i = 0; code[i] != '\0'; i++) {
char c = code[i]; char c = code[i];
@ -38,6 +38,11 @@ void check_brackets(const char *code) {
int main() { int main() {
char code[100]; char code[100];
if (fgets(code, sizeof(code), stdin) != NULL) { 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); check_brackets(code);
} }
return 0; return 0;