diff --git a/cv7/program.c b/cv7/program.c index 69e94ce..b45f611 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -81,7 +81,10 @@ struct tree* read_tree() { // Read a line from stdin char* r = fgets(buffer, SIZE, stdin); - assert(r); // Ensure reading was successful + if (r == NULL) { + fprintf(stderr, "Error: Failed to read input\n"); + exit(1); // Exit the program if reading fails + } // Allocate memory for a new tree node struct tree* node = calloc(1, sizeof(struct tree)); @@ -105,6 +108,7 @@ struct tree* read_tree() { return node; } + int main() { int counter = 0; struct tree *root = read_tree(&counter); // Try reading the tree