#include #include #include int main() { int32_t floor = 0; FILE *file = fopen("input", "r"); if (file == NULL) { perror("Error opening file."); return 1; } char buffer[256]; while (fgets(buffer, sizeof(buffer), file) != NULL) { uint16_t length = strlen(buffer); for (uint16_t i = 0; i < length; i++) { if (buffer[i] == '(') floor++; else if(buffer[i] == ')') floor--; } } if (ferror(file)) { perror("Error reading from file."); return 1; } fclose(file); printf("floor: %i\n", floor); return 0; }